<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  
  <title>蓝湖畔淅淅沥沥的雨</title>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <meta property="og:type" content="website">
<meta property="og:title" content="蓝湖畔淅淅沥沥的雨">
<meta property="og:url" content="http://example.com/page/2/index.html">
<meta property="og:site_name" content="蓝湖畔淅淅沥沥的雨">
<meta property="og:locale" content="zh_CN">
<meta property="article:author" content="StarsWhisper">
<meta name="twitter:card" content="summary">
  
    <link rel="alternate" href="/atom.xml" title="蓝湖畔淅淅沥沥的雨" type="application/atom+xml">
  
  
    <link rel="icon" href="/favicon.png">
  
  
    <link href="//fonts.googleapis.com/css?family=Source+Code+Pro" rel="stylesheet" type="text/css">
  
  
<link rel="stylesheet" href="/css/style.css">

  
<link rel="stylesheet" href="/plugin/bganimation/bg.css">

  

  <link href="https://cdnjs.cloudflare.com/ajax/libs/KaTeX/0.10.0/katex.min.css" rel="stylesheet" type="text/css">
<meta name="generator" content="Hexo 6.1.0"></head>

<body>
  <div id="container">
    <div id="wrap">
      <div class="outer">
        <div class="widget-wrap mobile-header">
  <h3 class="widget-title"></h3>
  <div class="widget">
    <img class="avatar" src="/images/avatar.png">
    <h2 class="author">StarsWhisper</h2>
    <h3 class="description"></h3>
    <div class="count-box">
      <a href="/archives"><div><strong>75</strong><br>文章</div></a>
      <a href="/categories"><div><strong>31</strong><br>分类</div></a>
      <a href="/tags"><div><strong>56</strong><br>标签</div></a>
    </div>
    <ul class="blog-link">
     
          <a href="/" title="Home">
            <li>主页</li>
          </a>
        
          <a href="/archives" title="Archives">
            <li>归档</li>
          </a>
        
          <a href="/categories" title="Categories">
            <li>分类</li>
          </a>
        
          <a href="/tags" title="Tags">
            <li>标签</li>
          </a>
        
          <a href="/knightabout" title="Knightabout">
            <li>关于</li>
          </a>
        
          <a href="/bridges" title="Bridges">
            <li>传送门</li>
          </a>
        
          <a href="/announcement" title="Announcement">
            <li>公告</li>
          </a>
        
    </ul>
  </div>
</div>

        <section id="main">
  
    <article id="post-【学习记录】【python】【opencv】自学简要记录（未完）" class="wow slideInRight article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/1444/11/11/%E3%80%90%E5%AD%A6%E4%B9%A0%E8%AE%B0%E5%BD%95%E3%80%91%E3%80%90python%E3%80%91%E3%80%90opencv%E3%80%91%E8%87%AA%E5%AD%A6%E7%AE%80%E8%A6%81%E8%AE%B0%E5%BD%95%EF%BC%88%E6%9C%AA%E5%AE%8C%EF%BC%89/" class="article-date">
  <time class="post-time" datetime="1444-11-11T03:06:11.000Z" itemprop="datePublished">
    <span class="post-month">11月</span><br/>
    <span class="post-day">11</span>
  </time>
</a>
   
  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/1444/11/11/%E3%80%90%E5%AD%A6%E4%B9%A0%E8%AE%B0%E5%BD%95%E3%80%91%E3%80%90python%E3%80%91%E3%80%90opencv%E3%80%91%E8%87%AA%E5%AD%A6%E7%AE%80%E8%A6%81%E8%AE%B0%E5%BD%95%EF%BC%88%E6%9C%AA%E5%AE%8C%EF%BC%89/">【已重置】【学习记录】【python】【opencv】自学简要记录</a>
    </h1>
  

        <div>
          
  <div class="article-category">
    <a class="article-category-link" href="/categories/%E5%9F%BA%E7%A1%80%E7%9F%A5%E8%AF%86/">基础知识</a>,<a class="article-category-link" href="/categories/%E5%9F%BA%E7%A1%80%E7%9F%A5%E8%AF%86/python/">python</a>,<a class="article-category-link" href="/categories/%E5%9F%BA%E7%A1%80%E7%9F%A5%E8%AF%86/python/opencv/">opencv</a>
  </div>

          
              

          
        </div>
      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <h2 id="说明-2022-05-06"><a class="markdownIt-Anchor" href="#说明-2022-05-06"></a> 说明 - 2022 - 05 - 06</h2>
<p>已经完成人工重置，发布时间设定在1444年11月11日，表示这篇博文写于博客建立之前，并于为重置的远古文章区分。</p>
<h2 id="说明-2022-05-05"><a class="markdownIt-Anchor" href="#说明-2022-05-05"></a> <s>说明 - 2022-05-05</s></h2>
<p><s>本篇博客为本人原创, 原发布于CSDN, 在搭建个人博客后使用爬虫批量爬取并挂到个人博客, 出于一些技术原因博客未能完全还原到初始版本(而且我懒得修改), 在观看体验上会有一些瑕疵 ,若有需求会发布重制版总结性新博客。发布时间统一定为1111年11月11日。钦此。</s></p>
<p><em>自学记录 不专业</em></p>
<h2 id="001-基础-读取与保存"><a class="markdownIt-Anchor" href="#001-基础-读取与保存"></a> 001 基础-读取与保存</h2>
<p><strong>读取图像</strong></p>
 <figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#读入图像 cv2.imread(filepath,flags)</span></span><br><span class="line"><span class="string">&#x27;&#x27;&#x27;</span></span><br><span class="line"><span class="string">flags参数的取值：</span></span><br><span class="line"><span class="string">cv2.IMREAD_COLOR：默认，载入一个彩色图像，忽略透明度   可用1代替</span></span><br><span class="line"><span class="string">cv2.IMREAD_GRAYSCALE：载入一个灰阶图像  可用0代替</span></span><br><span class="line"><span class="string">cv2.IMREAD_UNCHANGED：载入一个包含 Alpha 通道（透明度）的图像   可用-1代替</span></span><br><span class="line"><span class="string">&#x27;&#x27;&#x27;</span></span><br><span class="line">img1=cv2.imread(<span class="string">&#x27;imgs/lx.jpg&#x27;</span>,<span class="number">0</span>)</span><br><span class="line"></span><br></pre></td></tr></table></figure>
<p><strong>显示图像</strong></p>
 <figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#显示图像   cv2.imshow(wname,img)</span></span><br><span class="line"><span class="string">&#x27;&#x27;&#x27;</span></span><br><span class="line"><span class="string">wname  窗口的名字 window name</span></span><br><span class="line"><span class="string">img 要显示的图像 窗口他大小为自动调整图片大小</span></span><br><span class="line"><span class="string">&#x27;&#x27;&#x27;</span></span><br><span class="line">cv2.imshow(<span class="string">&#x27;lxSHOW&#x27;</span>,img1)</span><br><span class="line">key=cv2.waitKey(<span class="number">0</span>)</span><br><span class="line">cv2.destroyWindow(<span class="string">&#x27;lxSHOW&#x27;</span>)</span><br><span class="line"><span class="comment">#cv2.destroyAllWindows()</span></span><br><span class="line"><span class="keyword">if</span> key==<span class="number">27</span>:</span><br><span class="line">    <span class="built_in">print</span>(<span class="string">&#x27;Key_ESC has been pressed&#x27;</span>)</span><br><span class="line"></span><br></pre></td></tr></table></figure>
<p><strong>保存图像</strong></p>
  <figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#保存图像 cv2.imwrite(file，img，num)</span></span><br><span class="line"><span class="string">&#x27;&#x27;&#x27;</span></span><br><span class="line"><span class="string">file 文件名</span></span><br><span class="line"><span class="string">img  要保存的图像</span></span><br><span class="line"><span class="string">&#x27;&#x27;&#x27;</span></span><br><span class="line"><span class="comment">#其中可选参数num</span></span><br><span class="line"><span class="string">&#x27;&#x27;&#x27;</span></span><br><span class="line"><span class="string">它针对特定的格式：对于JPEG，其表示的是图像的质量，用0 - 100的整数表示，默认95;对于png ,第三个参数表示的是压缩级别。默认为3.</span></span><br><span class="line"><span class="string">cv2.IMWRITE_JPEG_QUALITY类型为 long ,必须转换成 int</span></span><br><span class="line"><span class="string">cv2.IMWRITE_PNG_COMPRESSION, 从0到9 压缩级别越高图像越小。</span></span><br><span class="line"><span class="string">&#x27;&#x27;&#x27;</span></span><br><span class="line">cv2.imwrite(<span class="string">&#x27;imgs_save/lxGrey1.jpg&#x27;</span>,img1,[<span class="built_in">int</span>(cv2.IMWRITE_JPEG_QUALITY),<span class="number">95</span>])</span><br><span class="line">cv2.imwrite(<span class="string">&#x27;imgs_save/lxGrey2.png&#x27;</span>,img1,[<span class="built_in">int</span>(cv2.IMWRITE_PNG_COMPRESSION),<span class="number">3</span>])</span><br><span class="line"><span class="comment"># jpg属于有损压缩，是以图片的清晰度为代价的，数字越小，压缩比越高，图片质量损失越严重</span></span><br><span class="line"><span class="comment"># png属于无损压缩，数字0-9，数字越低，压缩比越低</span></span><br><span class="line"></span><br></pre></td></tr></table></figure>
<p><strong>读取视频文件</strong></p>
 <figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#读取视频 cv2.VideoCapture()</span></span><br><span class="line"><span class="string">&#x27;&#x27;&#x27;</span></span><br><span class="line"><span class="string">参数为0 : 调用笔记本内置摄像头</span></span><br><span class="line"><span class="string">参数为其他数字 : 不是很清楚，尝试用OBS开了个虚拟摄像头参数调成1可以调用</span></span><br><span class="line"><span class="string">参数为路径 : 打开视频</span></span><br><span class="line"><span class="string">&#x27;&#x27;&#x27;</span></span><br><span class="line"><span class="comment">#检查摄像头初始化是否成功 cv2.VideoCapture.isOpened()</span></span><br><span class="line"><span class="string">&#x27;&#x27;&#x27;</span></span><br><span class="line"><span class="string">成功返回Ture</span></span><br><span class="line"><span class="string">&#x27;&#x27;&#x27;</span></span><br><span class="line"><span class="comment">#读取视频的一帧 cv2.VideoCapture.read()</span></span><br><span class="line"><span class="string">&#x27;&#x27;&#x27;</span></span><br><span class="line"><span class="string">每次调用便读取一帧 返回值为 ret,frame</span></span><br><span class="line"><span class="string">ret ： 布尔类型，如果正确读取便返回Ture</span></span><br><span class="line"><span class="string">frame : 每一帧的图像，三维矩阵</span></span><br><span class="line"><span class="string">&#x27;&#x27;&#x27;</span></span><br><span class="line"><span class="comment">#释放摄像头 cv2.VideoCapture.release()</span></span><br><span class="line"></span><br><span class="line"><span class="comment">#vd = cv2.VideoCapture(&#x27;videos/mgm.mkv&#x27;)</span></span><br><span class="line">vd =  cv2.VideoCapture(<span class="number">1</span>)</span><br><span class="line"><span class="keyword">if</span> vd.isOpened():</span><br><span class="line">    ret, frame = vd.read()</span><br><span class="line">    <span class="comment">#frame = cv2.resize(frame,(1080,720))</span></span><br><span class="line"><span class="keyword">else</span>:</span><br><span class="line">    ret = <span class="literal">False</span></span><br><span class="line">    </span><br><span class="line"><span class="keyword">while</span> ret:</span><br><span class="line">    cv2.imshow(<span class="string">&#x27;TheVideo&#x27;</span>,frame)</span><br><span class="line">    <span class="comment">#利用waitKey设置每一帧的停顿时间 如果你按了ESC(27)则直接退出 </span></span><br><span class="line">    <span class="comment">#显然当waitKey为0时只有按键才会换帧</span></span><br><span class="line">    <span class="keyword">if</span> cv2.waitKey(<span class="number">1</span>) &amp; <span class="number">0xFF</span> == <span class="number">27</span>:</span><br><span class="line">        <span class="keyword">break</span></span><br><span class="line">    ret, frame = vd.read()</span><br><span class="line">    <span class="comment">#frame = cv2.resize(frame,(1080,720))</span></span><br><span class="line">    </span><br><span class="line">vd.release()</span><br><span class="line">cv2.destroyAllWindows() </span><br><span class="line"></span><br></pre></td></tr></table></figure>
<p>​</p>
<h2 id="002基础-简单变换"><a class="markdownIt-Anchor" href="#002基础-简单变换"></a> 002基础-简单变换</h2>
<p><strong>裁剪</strong></p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#图片裁剪</span></span><br><span class="line">img_cliped = img[<span class="number">100</span>:<span class="number">600</span>,<span class="number">50</span>:<span class="number">1050</span>]</span><br><span class="line"></span><br><span class="line">cv2.imshow(<span class="string">&#x27;Clip&#x27;</span>, img_cliped)</span><br><span class="line">cv2.waitKey(<span class="number">0</span>)</span><br><span class="line">cv2.destroyWindow(<span class="string">&#x27;Clip&#x27;</span>)</span><br><span class="line"></span><br></pre></td></tr></table></figure>
<p><strong>改变图片大小</strong></p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#图片改变大小 cv2.resize(img,(整形宽，整形高),fx,fy)</span></span><br><span class="line"><span class="string">&#x27;&#x27;&#x27;</span></span><br><span class="line"><span class="string">可以给出固定的宽高</span></span><br><span class="line"><span class="string">也可以给(0,0)按倍数变化(fx,fy)</span></span><br><span class="line"><span class="string">&#x27;&#x27;&#x27;</span></span><br><span class="line">img_resized = cv2.resize(img, (<span class="number">1200</span>,<span class="number">500</span>)) <span class="comment">#(宽1200，高500)</span></span><br><span class="line">img_resized2 = cv2.resize(img, (<span class="number">0</span>,<span class="number">0</span>), fx = <span class="number">0.4</span>, fy = <span class="number">0.4</span>)</span><br><span class="line"></span><br><span class="line">cv2.imshow(<span class="string">&#x27;Resize&#x27;</span>, img_resized)</span><br><span class="line">cv2.imshow(<span class="string">&#x27;Resize2&#x27;</span>, img_resized2)</span><br><span class="line">cv2.waitKey(<span class="number">0</span>)</span><br><span class="line">cv2.destroyAllWindows()</span><br><span class="line"></span><br></pre></td></tr></table></figure>
<p><strong>改变图片大小-自己实现</strong></p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#图片改变大小 自己实现</span></span><br><span class="line"><span class="keyword">import</span> numpy <span class="keyword">as</span> np</span><br><span class="line"><span class="keyword">import</span> cv2</span><br><span class="line"></span><br><span class="line">img=cv2.imread(<span class="string">&#x27;imgs/lx.jpg&#x27;</span>,<span class="number">1</span>)</span><br><span class="line">rate=<span class="number">0.4</span></span><br><span class="line"></span><br><span class="line">imgH,imgW,imgN=img.shape</span><br><span class="line">newH,newW,newN=<span class="built_in">int</span>(imgH*rate),<span class="built_in">int</span>(imgW*rate),imgN</span><br><span class="line"></span><br><span class="line">new=np.zeros((newH,newW,newN),np.uint8)</span><br><span class="line"></span><br><span class="line"><span class="keyword">for</span> i <span class="keyword">in</span> <span class="built_in">range</span>(newH):</span><br><span class="line">    <span class="keyword">for</span> j <span class="keyword">in</span> <span class="built_in">range</span>(newW):</span><br><span class="line">        ii=<span class="built_in">int</span>(i*(imgH*<span class="number">1.0</span>/newH))</span><br><span class="line">        jj=<span class="built_in">int</span>(j*(imgW*<span class="number">1.0</span>/newW))</span><br><span class="line">        new[i,j]=img[ii,jj]</span><br><span class="line"></span><br><span class="line">cv2.imshow(<span class="string">&#x27;lxRESIZED&#x27;</span>,new)</span><br><span class="line"><span class="comment">#cv2.imshow(&#x27;lxRESIZED&#x27;,np.dstack((new[:,:,0],new[:,:,1],new[:,:,2])))</span></span><br><span class="line">cv2.waitKey(<span class="number">0</span>)</span><br><span class="line">cv2.destroyAllWindows()</span><br><span class="line"></span><br></pre></td></tr></table></figure>
<p><strong>图片反转</strong></p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#图片反转 cv2.flip(img,flipcode)</span></span><br><span class="line"></span><br><span class="line"><span class="string">&#x27;&#x27;&#x27;</span></span><br><span class="line"><span class="string">#flipcode=0 沿x轴翻转</span></span><br><span class="line"><span class="string">#flipcode&gt;0 沿y轴翻转</span></span><br><span class="line"><span class="string">#flipcode&lt;0 x,y同时翻转</span></span><br><span class="line"><span class="string">&#x27;&#x27;&#x27;</span></span><br><span class="line">flipX=cv2.flip(img,<span class="number">0</span>)</span><br><span class="line">flipY=cv2.flip(img,<span class="number">1</span>)</span><br><span class="line">flipXY=cv2.flip(img,-<span class="number">1</span>)</span><br><span class="line"></span><br><span class="line">cv2.imshow(<span class="string">&#x27;lxFLIPx&#x27;</span>,flipX)</span><br><span class="line">cv2.imshow(<span class="string">&#x27;lxFLIPy&#x27;</span>,flipY)</span><br><span class="line">cv2.imshow(<span class="string">&#x27;lxFLIPxy&#x27;</span>,flipXY)</span><br><span class="line"></span><br><span class="line">cv2.waitKey(<span class="number">0</span>)</span><br><span class="line">cv2.destroyAllWindows()</span><br><span class="line"></span><br></pre></td></tr></table></figure>
<p><strong>颜色通道分离与合并</strong></p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#颜色通道分离与合并</span></span><br><span class="line">img = cv2.imread(<span class="string">&#x27;imgs/sky1.png&#x27;</span>)</span><br><span class="line">imgC = img.copy()</span><br><span class="line"></span><br><span class="line">B,G,R = cv2.split(img)</span><br><span class="line">zero = np.zeros_like(B)</span><br><span class="line">imgC[:,:,<span class="number">1</span>] = <span class="number">0</span></span><br><span class="line">imgC[:,:,<span class="number">2</span>] = <span class="number">0</span></span><br><span class="line"></span><br><span class="line">cv2.imshow(<span class="string">&#x27;B1&#x27;</span>,np.dstack((B,zero,zero)))</span><br><span class="line">cv2.imshow(<span class="string">&#x27;B2&#x27;</span>,cv2.merge((B,zero,zero)))</span><br><span class="line">cv2.imshow(<span class="string">&#x27;B3&#x27;</span>,imgC)</span><br><span class="line"></span><br><span class="line">cv2.waitKey(<span class="number">0</span>)</span><br><span class="line">cv2.destroyAllWindows()</span><br><span class="line"></span><br></pre></td></tr></table></figure>
<p><strong>cv2.cvtColor 通道转换</strong></p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">img = cv2.imread(<span class="string">&#x27;imgs/sky1.png&#x27;</span>,<span class="number">1</span>)</span><br><span class="line">imgBGR = cv2.cvtColor(img,cv2.COLOR_RGB2BGR)</span><br><span class="line">imgGRAY = cv2.cvtColor(img,cv2.COLOR_RGB2GRAY)</span><br><span class="line">fig, ax = plt.subplots(<span class="number">1</span>,<span class="number">2</span>)</span><br><span class="line">ax[<span class="number">0</span>].imshow(imgBGR)</span><br><span class="line">ax[<span class="number">1</span>].imshow(imgGRAY,cmap = <span class="string">&#x27;gray&#x27;</span>)</span><br><span class="line">plt.savefig(<span class="string">&#x27;imgs_save/123.png&#x27;</span>)</span><br><span class="line">	</span><br></pre></td></tr></table></figure>
<img src="/1444/11/11/%E3%80%90%E5%AD%A6%E4%B9%A0%E8%AE%B0%E5%BD%95%E3%80%91%E3%80%90python%E3%80%91%E3%80%90opencv%E3%80%91%E8%87%AA%E5%AD%A6%E7%AE%80%E8%A6%81%E8%AE%B0%E5%BD%95%EF%BC%88%E6%9C%AA%E5%AE%8C%EF%BC%89/20210226121737443.png" class="" title="在这里插入图片描述">
<p><strong>简单数值计算</strong></p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#数值计算</span></span><br><span class="line"><span class="string">&#x27;&#x27;&#x27;</span></span><br><span class="line"><span class="string">numpy(直接计算) 越界会%256</span></span><br><span class="line"><span class="string">cv2.add(img1,img2) 越界会保留255</span></span><br><span class="line"><span class="string">&#x27;&#x27;&#x27;</span></span><br><span class="line">img = cv2.imread(<span class="string">&#x27;imgs/sky1.png&#x27;</span>)</span><br><span class="line">another = np.full_like(img,<span class="number">225</span>)</span><br><span class="line">another_img = cv2.add(img,another)</span><br><span class="line">cv2.imshow(<span class="string">&#x27;Add_50&#x27;</span>,img+<span class="number">50</span>)</span><br><span class="line">cv2.imshow(<span class="string">&#x27;Add_80&#x27;</span>,img+<span class="number">80</span>)</span><br><span class="line">cv2.imshow(<span class="string">&#x27;another_img&#x27;</span>,another_img)</span><br><span class="line">cv2.waitKey(<span class="number">0</span>)</span><br><span class="line">cv2.destroyAllWindows()</span><br><span class="line"></span><br></pre></td></tr></table></figure>
<p><strong>cv2.addWeighted</strong></p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#重叠两张图片</span></span><br><span class="line">img1 = cv2.imread(<span class="string">&#x27;imgs/sky1.png&#x27;</span>)</span><br><span class="line">img2 = cv2.imread(<span class="string">&#x27;imgs/lx.jpg&#x27;</span>)</span><br><span class="line">img1_resized = cv2.resize(img1,(img2.shape[<span class="number">1</span>],img2.shape[<span class="number">0</span>]))</span><br><span class="line">img_mix = cv2.addWeighted(img2,<span class="number">0.5</span>,img1_resized,<span class="number">0.5</span>,<span class="number">0</span>)</span><br><span class="line">cv2.imshow(<span class="string">&#x27;MIX&#x27;</span>,img_mix)</span><br><span class="line">cv2.imshow(<span class="string">&#x27;MIX2&#x27;</span>,cv2.add((img1_resized*<span class="number">0.5</span>).astype(np.int8),(img2*<span class="number">0.5</span>).astype(np.int8))-<span class="number">120</span>)</span><br><span class="line">cv2.waitKey(<span class="number">0</span>)</span><br><span class="line">cv2.destroyAllWindows()</span><br><span class="line"><span class="string">&#x27;&#x27;&#x27;</span></span><br><span class="line"><span class="string">图MIX2手动实现了一下结果太亮了，所以最后-120达到和函数差不多的效果</span></span><br><span class="line"><span class="string">其中的原因改日探究</span></span><br><span class="line"><span class="string">&#x27;&#x27;&#x27;</span></span><br><span class="line"></span><br></pre></td></tr></table></figure>
<h2 id="003-基础-用matplotlib画图像"><a class="markdownIt-Anchor" href="#003-基础-用matplotlib画图像"></a> 003 基础-用matplotlib画图像</h2>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">img = cv2.imread(<span class="string">&#x27;imgs/lx.jpg&#x27;</span>,<span class="number">1</span>)</span><br><span class="line"></span><br><span class="line"><span class="comment">#在matplotlib中画出图片 matplotlib.pyplot.imshow(img)</span></span><br><span class="line"><span class="comment">#vc2 是BGR模式，matplotlib.pyplot是RGB模式 所以颜色会不一样</span></span><br><span class="line">B,G,R = cv2.split(img)</span><br><span class="line">img_rgb = cv2.merge((R,G,B))</span><br><span class="line">plt.imshow(img_rgb)</span><br><span class="line"></span><br></pre></td></tr></table></figure>
<p>​</p>
<h2 id="004-阈值"><a class="markdownIt-Anchor" href="#004-阈值"></a> 004 阈值</h2>
<blockquote>
<p>#def threshold(src, thresh, maxval, type, dst=None):<br />
‘’’<br />
设置固定级别的阈值应用于多通道矩阵<br />
例如，将 <strong>灰度图像</strong> 变换二值图像，或去除指定级别的噪声，或过滤掉过小或者过大的像素点；<br />
Argument:<br />
src: 原图像<br />
dst: 目标图像<br />
thresh: 阈值<br />
type: 指定阈值类型；下面会列出具体类型；<br />
maxval: 当type指定为THRESH_BINARY或THRESH_BINARY_INV时，需要设置该值；<br />
‘’’</p>
</blockquote>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><span class="line">gray = cv2.imread(<span class="string">&#x27;imgs/sky1.png&#x27;</span>,<span class="number">0</span>)</span><br><span class="line">thresh = <span class="number">127</span></span><br><span class="line">maxval = <span class="number">255</span></span><br><span class="line"><span class="comment">#以阈值分割二值化为0和maxval </span></span><br><span class="line">ret, threshed1 = cv2.threshold(gray,thresh,maxval,cv2.THRESH_BINARY)      </span><br><span class="line"></span><br><span class="line"><span class="comment">#以阈值分割二值化为0和maxval</span></span><br><span class="line">ret, threshed2 = cv2.threshold(gray,thresh,maxval,cv2.THRESH_BINARY_INV)  </span><br><span class="line"></span><br><span class="line"><span class="comment">#小于阈值变为0</span></span><br><span class="line">ret, threshed3 = cv2.threshold(gray,thresh,maxval,cv2.THRESH_TOZERO)      </span><br><span class="line"></span><br><span class="line"><span class="comment">#大于阈值变为0</span></span><br><span class="line">ret, threshed4 = cv2.threshold(gray,thresh,maxval,cv2.THRESH_TOZERO_INV)  </span><br><span class="line"></span><br><span class="line"><span class="comment">#大于阈值变为阈值</span></span><br><span class="line">ret, threshed5 = cv2.threshold(gray,thresh,maxval,cv2.THRESH_TRUNC)      </span><br><span class="line"></span><br></pre></td></tr></table></figure>
<p>用matplotlib画图</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">fig, ax = plt.subplots(<span class="number">3</span>,<span class="number">2</span>,figsize = (<span class="number">10</span>,<span class="number">10</span>))</span><br><span class="line">ax[<span class="number">0</span>,<span class="number">0</span>].imshow(threshed1,cmap = <span class="string">&#x27;gray&#x27;</span>)</span><br><span class="line">ax[<span class="number">0</span>,<span class="number">1</span>].imshow(threshed2,cmap = <span class="string">&#x27;gray&#x27;</span>)</span><br><span class="line">ax[<span class="number">1</span>,<span class="number">0</span>].imshow(threshed3,cmap = <span class="string">&#x27;gray&#x27;</span>)</span><br><span class="line">ax[<span class="number">1</span>,<span class="number">1</span>].imshow(threshed4,cmap = <span class="string">&#x27;gray&#x27;</span>)</span><br><span class="line">ax[<span class="number">2</span>,<span class="number">0</span>].imshow(threshed5,cmap = <span class="string">&#x27;gray&#x27;</span>)</span><br><span class="line">ax[<span class="number">2</span>,<span class="number">1</span>].imshow(gray,cmap = <span class="string">&#x27;gray&#x27;</span>)</span><br><span class="line"></span><br></pre></td></tr></table></figure>
<img src="/1444/11/11/%E3%80%90%E5%AD%A6%E4%B9%A0%E8%AE%B0%E5%BD%95%E3%80%91%E3%80%90python%E3%80%91%E3%80%90opencv%E3%80%91%E8%87%AA%E5%AD%A6%E7%AE%80%E8%A6%81%E8%AE%B0%E5%BD%95%EF%BC%88%E6%9C%AA%E5%AE%8C%EF%BC%89/2021022319264149.png" class="" title="在这里插入图片描述">
<h2 id="005-平滑模糊处理-滤波"><a class="markdownIt-Anchor" href="#005-平滑模糊处理-滤波"></a> 005 平滑/模糊处理 // 滤波</h2>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br></pre></td><td class="code"><pre><span class="line">img = cv2.imread(<span class="string">&#x27;imgs/sky1.png&#x27;</span>,<span class="number">1</span>)</span><br><span class="line">lst = []</span><br><span class="line">name = [<span class="string">&#x27;blur&#x27;</span>,<span class="string">&#x27;boxFilter&#x27;</span>,<span class="string">&#x27;GaussianBlur&#x27;</span>,<span class="string">&#x27;madianBlur&#x27;</span>]</span><br><span class="line"></span><br><span class="line"><span class="comment">#均值滤波</span></span><br><span class="line">lst.append( cv2.blur(img,(<span class="number">19</span>,<span class="number">19</span>))                             )</span><br><span class="line"></span><br><span class="line"><span class="comment">#方框滤波 当normallize为True时等同于均值滤波</span></span><br><span class="line">lst.append( cv2.boxFilter(img,-<span class="number">1</span>,(<span class="number">19</span>,<span class="number">19</span>),normalize = <span class="literal">False</span>)   )</span><br><span class="line"></span><br><span class="line"><span class="comment">#高斯滤波</span></span><br><span class="line">lst.append( cv2.GaussianBlur(img,(<span class="number">19</span>,<span class="number">19</span>),sigmaX = <span class="number">864</span>)        )</span><br><span class="line"></span><br><span class="line"><span class="comment">#中值滤波</span></span><br><span class="line">lst.append( cv2.medianBlur(img,<span class="number">19</span>)                            )</span><br><span class="line"></span><br><span class="line">lst_save = lst.copy()</span><br><span class="line"></span><br><span class="line"><span class="keyword">for</span> i <span class="keyword">in</span> <span class="built_in">range</span>(<span class="built_in">len</span>(lst)):</span><br><span class="line">    b,g,r = cv2.split(lst[i])</span><br><span class="line">    lst[i] = cv2.merge((r,g,b))</span><br><span class="line"></span><br></pre></td></tr></table></figure>
<p>用matplotlib画图</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">fig, ax = plt.subplots(<span class="number">2</span>,<span class="number">2</span>,figsize = (<span class="number">10</span>,<span class="number">7</span>))</span><br><span class="line"><span class="keyword">for</span> i <span class="keyword">in</span> <span class="built_in">range</span>(<span class="built_in">len</span>(lst)):</span><br><span class="line">    ax[i//<span class="number">2</span>,i%<span class="number">2</span>].imshow(lst[i])</span><br><span class="line">    ax[i//<span class="number">2</span>,i%<span class="number">2</span>].set_title(name[i])</span><br><span class="line">plt.savefig(<span class="string">&#x27;imgs_save/blur.png&#x27;</span>)</span><br><span class="line"></span><br></pre></td></tr></table></figure>
<img src="/1444/11/11/%E3%80%90%E5%AD%A6%E4%B9%A0%E8%AE%B0%E5%BD%95%E3%80%91%E3%80%90python%E3%80%91%E3%80%90opencv%E3%80%91%E8%87%AA%E5%AD%A6%E7%AE%80%E8%A6%81%E8%AE%B0%E5%BD%95%EF%BC%88%E6%9C%AA%E5%AE%8C%EF%BC%89/20210223193542528.png" class="" title="在这里插入图片描述">
<h2 id="006-形态学-腐蚀膨胀-开闭梯度运算"><a class="markdownIt-Anchor" href="#006-形态学-腐蚀膨胀-开闭梯度运算"></a> 006 形态学-腐蚀/膨胀 开/闭/梯度运算</h2>
<p>形态学操作一般作用于 <strong>二值化图</strong> ，来连接相邻的元素或分离成独立的元素</p>
<p><strong>腐蚀</strong> erode：找局部最小<br />
图像与核卷积，找核覆盖范围内最小值</p>
<p><strong>膨胀</strong> dilate：找局部最大<br />
图像与核卷积，找核覆盖范围内最大值</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><span class="line">img = cv2.imread(<span class="string">&#x27;imgs/plainstar.png&#x27;</span>,<span class="number">0</span>)</span><br><span class="line"><span class="comment">#fig,ax = plt.subplots(2,1,figsize = (8,12))</span></span><br><span class="line"></span><br><span class="line">kernel = np.ones([<span class="number">3</span>,<span class="number">3</span>],dtype = np.int8)<span class="comment">#卷积核</span></span><br><span class="line"><span class="string">&#x27;&#x27;&#x27;</span></span><br><span class="line"><span class="string">以kernel作为卷积核</span></span><br><span class="line"><span class="string">参数iterations为迭代次数，iterations=2 代表进行两次腐蚀</span></span><br><span class="line"><span class="string">&#x27;&#x27;&#x27;</span></span><br><span class="line">erosion = cv2.erode(img,kernel,iterations = <span class="number">2</span>)</span><br><span class="line"><span class="comment">#ax[0].imshow(erosion,cmap = &#x27;gray&#x27;)</span></span><br><span class="line"></span><br><span class="line">dilation_after_erosion = cv2.dilate(erosion,kernel,iterations = <span class="number">2</span>)</span><br><span class="line"><span class="comment">#ax[1].imshow(dilation_after_erosion,cmap = &#x27;gray&#x27;)</span></span><br><span class="line"></span><br><span class="line">tot = np.vstack([img,erosion,dilation_after_erosion])</span><br><span class="line">cv2.imwrite(<span class="string">&#x27;imgs_save/plainstar_open.png&#x27;</span>,tot)</span><br><span class="line"></span><br></pre></td></tr></table></figure>
<p>原图+腐蚀图+腐蚀图的膨胀图：</p>
<img src="/1444/11/11/%E3%80%90%E5%AD%A6%E4%B9%A0%E8%AE%B0%E5%BD%95%E3%80%91%E3%80%90python%E3%80%91%E3%80%90opencv%E3%80%91%E8%87%AA%E5%AD%A6%E7%AE%80%E8%A6%81%E8%AE%B0%E5%BD%95%EF%BC%88%E6%9C%AA%E5%AE%8C%EF%BC%89/20210223230722478.png" class="" title="在这里插入图片描述">
<p><strong>开运算</strong> ：先腐蚀后膨胀<br />
<strong>闭运算</strong> ：先膨胀后腐蚀<br />
上方腐蚀与膨胀的示例代码就是一个开运算，下方代码时开运算+闭运算</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br></pre></td><td class="code"><pre><span class="line">img = cv2.imread(<span class="string">&#x27;imgs/plainstar.png&#x27;</span>,<span class="number">0</span>)</span><br><span class="line">kernel = np.ones([<span class="number">5</span>,<span class="number">5</span>],dtype = np.int8)<span class="comment">#卷积核</span></span><br><span class="line"><span class="string">&#x27;&#x27;&#x27;</span></span><br><span class="line"><span class="string">以kernel作为卷积核</span></span><br><span class="line"><span class="string">参数cv2.MORPH_OPEN表示开运算</span></span><br><span class="line"><span class="string">参数cv2.MORPH_CLOSE表示闭运算</span></span><br><span class="line"><span class="string">&#x27;&#x27;&#x27;</span></span><br><span class="line">opening = cv2.morphologyEx(img,cv2.MORPH_OPEN,kernel)</span><br><span class="line">closing = cv2.morphologyEx(img,cv2.MORPH_CLOSE,kernel)</span><br><span class="line"></span><br><span class="line">tot = np.vstack([opening,closing])</span><br><span class="line">cv2.imwrite(<span class="string">&#x27;imgs_save/plainstar_opening_and_closing.png&#x27;</span>,tot)</span><br><span class="line"></span><br></pre></td></tr></table></figure>
<p>开运算与闭运算效果：</p>
<img src="/1444/11/11/%E3%80%90%E5%AD%A6%E4%B9%A0%E8%AE%B0%E5%BD%95%E3%80%91%E3%80%90python%E3%80%91%E3%80%90opencv%E3%80%91%E8%87%AA%E5%AD%A6%E7%AE%80%E8%A6%81%E8%AE%B0%E5%BD%95%EF%BC%88%E6%9C%AA%E5%AE%8C%EF%BC%89/20210223231418739.png" class="" title="在这里插入图片描述"> 
<p><strong>梯度运算</strong> ：膨胀-腐蚀</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line">img = cv2.imread(<span class="string">&#x27;imgs/cloud.png&#x27;</span>)</span><br><span class="line">kernel = np.ones([<span class="number">5</span>,<span class="number">5</span>],dtype = np.int8)<span class="comment">#卷积核</span></span><br><span class="line"><span class="string">&#x27;&#x27;&#x27;</span></span><br><span class="line"><span class="string">梯度运算：膨胀-腐蚀</span></span><br><span class="line"><span class="string">参数cv2.MORPH_GRADIENT代表梯度运算</span></span><br><span class="line"><span class="string">&#x27;&#x27;&#x27;</span></span><br><span class="line">gradient = cv2.morphologyEx(img,cv2.MORPH_GRADIENT,kernel)</span><br><span class="line"></span><br><span class="line">tot = np.vstack([img,gradient])</span><br><span class="line">cv2.imwrite(<span class="string">&#x27;imgs_save/cloud_gradient.png&#x27;</span>,tot)</span><br><span class="line"></span><br></pre></td></tr></table></figure>
<img src="/1444/11/11/%E3%80%90%E5%AD%A6%E4%B9%A0%E8%AE%B0%E5%BD%95%E3%80%91%E3%80%90python%E3%80%91%E3%80%90opencv%E3%80%91%E8%87%AA%E5%AD%A6%E7%AE%80%E8%A6%81%E8%AE%B0%E5%BD%95%EF%BC%88%E6%9C%AA%E5%AE%8C%EF%BC%89/20210223232605766.png" class="" title="在这里插入图片描述"> 
<p>刚才的五角星进行梯度运算</p>
<img src="/1444/11/11/%E3%80%90%E5%AD%A6%E4%B9%A0%E8%AE%B0%E5%BD%95%E3%80%91%E3%80%90python%E3%80%91%E3%80%90opencv%E3%80%91%E8%87%AA%E5%AD%A6%E7%AE%80%E8%A6%81%E8%AE%B0%E5%BD%95%EF%BC%88%E6%9C%AA%E5%AE%8C%EF%BC%89/2021022323281133.png" class="" title="在这里插入图片描述">
<h2 id="007-梯度处理边缘检测轮廓检测"><a class="markdownIt-Anchor" href="#007-梯度处理边缘检测轮廓检测"></a> 007 梯度处理/边缘检测/轮廓检测</h2>
<p><strong>sobel算子梯度处理</strong></p>
<blockquote>
<p>cv2.Sobel(src, ddepth, dx, dy[, dst[, ksize[, scale[, delta[,<br />
borderType]]]]])</p>
<hr />
<p>前四个是必须的参数：<br />
第一个参数是需要处理的图像；<br />
第二个参数是图像的深度，-1表示采用的是与原图像相同的深度。目标图像的深度必须大于等于原图像的深度；<br />
dx和dy表示的是求导的阶数，0表示这个方向上没有求导，一般为0、1、2。<br />
其后是可选的参数：</p>
<hr />
<p>ksize是Sobel算子的大小，必须为1、3、5、7。<br />
scale是缩放导数的比例常数，默认情况下没有伸缩系数；<br />
delta是一个可选的增量，将会加到最终的dst中，同样，默认情况下没有额外的值加到dst中；<br />
borderType是判断图像边界的模式。这个参数默认值为cv2.BORDER_DEFAULT。</p>
</blockquote>
<blockquote>
<p>cv2.addWeighted(src1, alpha, src2, beta, gamma[, dst[, dtype]])</p>
<hr />
<p>可以用来合并两个方向的梯度图</p>
</blockquote>
<blockquote>
<p>cv2.convertScaleAbs(src[, dst[, alpha[, beta]]])</p>
<hr />
<p>Sobel函数求完导数后会有负值，还有会大于255的值,所以需要更大的数据类型（所以为什么深度的参数填的是数据类型？？？），最后用convertScaleAbs()函数将其转回原来的uint8形式</p>
</blockquote>
<p>存疑⬆</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><span class="line">cloud = cv2.imread(<span class="string">&#x27;imgs/sky1.png&#x27;</span>,<span class="number">0</span>)</span><br><span class="line">cloud = cv2.resize(cloud,(<span class="number">0</span>,<span class="number">0</span>),fx = <span class="number">0.3</span>,fy = <span class="number">0.3</span>)</span><br><span class="line"></span><br><span class="line">cloudX = cv2.Sobel(cloud,cv2.CV_64F,<span class="number">1</span>,<span class="number">0</span>)</span><br><span class="line">cloudY = cv2.Sobel(cloud,cv2.CV_64F,<span class="number">0</span>,<span class="number">1</span>)</span><br><span class="line"></span><br><span class="line">cloudAbsX = cv2.convertScaleAbs(cloudX)</span><br><span class="line">cloudAbsY = cv2.convertScaleAbs(cloudY)</span><br><span class="line"></span><br><span class="line">cloudXY = cv2.addWeighted(cloudX,<span class="number">0.5</span>,cloudY,<span class="number">0.5</span>,<span class="number">0</span>)</span><br><span class="line">cloudAbsXY = cv2.addWeighted(cloudAbsX,<span class="number">0.5</span>,cloudAbsY,<span class="number">0.5</span>,<span class="number">0</span>)</span><br><span class="line"></span><br><span class="line">tot = np.hstack([np.vstack([cloud,cloudX,cloudY,cloudXY]), np.vstack([cloud,cloudAbsX,cloudAbsY,cloudAbsXY])])</span><br><span class="line">cv2.imshow(<span class="string">&#x27;tot&#x27;</span>,tot)</span><br><span class="line">cv2.waitKey(<span class="number">0</span>)</span><br><span class="line">cv2.destroyAllWindows()</span><br><span class="line">cv2.imwrite(<span class="string">&#x27;imgs_save/cloud_grad.png&#x27;</span>,tot)</span><br><span class="line"></span><br></pre></td></tr></table></figure>
<img src="/1444/11/11/%E3%80%90%E5%AD%A6%E4%B9%A0%E8%AE%B0%E5%BD%95%E3%80%91%E3%80%90python%E3%80%91%E3%80%90opencv%E3%80%91%E8%87%AA%E5%AD%A6%E7%AE%80%E8%A6%81%E8%AE%B0%E5%BD%95%EF%BC%88%E6%9C%AA%E5%AE%8C%EF%BC%89/20210224140134927.png" class="" title="在这里插入图片描述">  
<p>此外还查到scharr算子laplacian算子 没有深入了解</p>
<p><strong>Canny边缘检测</strong><br />
原理（查资料）：<a target="_blank" rel="noopener" href="https://www.cnblogs.com/techyan1990/p/7291771.html">https://www.cnblogs.com/techyan1990/p/7291771.html</a></p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><span class="line">town = cv2.imread(<span class="string">&#x27;imgs/town.jpg&#x27;</span>,<span class="number">0</span>)</span><br><span class="line">town = cv2.resize(town,(<span class="number">0</span>,<span class="number">0</span>),fx = <span class="number">0.3</span>,fy = <span class="number">0.3</span>)</span><br><span class="line"></span><br><span class="line"><span class="string">&#x27;&#x27;&#x27;</span></span><br><span class="line"><span class="string">见canny双阈值检测</span></span><br><span class="line"><span class="string">后两个参数表示最小梯度minval、最大梯度maxval</span></span><br><span class="line"><span class="string">if   梯度 &gt;= maxval 则视为边界</span></span><br><span class="line"><span class="string">elif 梯度 &lt;= maxval 则不视为边界</span></span><br><span class="line"><span class="string">elif maxval &gt; 梯度 &gt; minval:</span></span><br><span class="line"><span class="string">    if   这里与边界相连, 视为边界</span></span><br><span class="line"><span class="string">    else 不视为边界</span></span><br><span class="line"><span class="string">&#x27;&#x27;&#x27;</span></span><br><span class="line">canny1 = cv2.Canny(town,<span class="number">80</span>,<span class="number">130</span>)</span><br><span class="line">canny2 = cv2.Canny(town,<span class="number">105</span>,<span class="number">155</span>)</span><br><span class="line">canny = np.hstack((canny1,canny2))</span><br><span class="line">cv2.imwrite(<span class="string">&#x27;imgs_save/town_canny1.png&#x27;</span>,canny)</span><br><span class="line"></span><br></pre></td></tr></table></figure>
<img src="/1444/11/11/%E3%80%90%E5%AD%A6%E4%B9%A0%E8%AE%B0%E5%BD%95%E3%80%91%E3%80%90python%E3%80%91%E3%80%90opencv%E3%80%91%E8%87%AA%E5%AD%A6%E7%AE%80%E8%A6%81%E8%AE%B0%E5%BD%95%EF%BC%88%E6%9C%AA%E5%AE%8C%EF%BC%89/20210225123904401.png" class="" title="在这里插入图片描述">  
<img src="/1444/11/11/%E3%80%90%E5%AD%A6%E4%B9%A0%E8%AE%B0%E5%BD%95%E3%80%91%E3%80%90python%E3%80%91%E3%80%90opencv%E3%80%91%E8%87%AA%E5%AD%A6%E7%AE%80%E8%A6%81%E8%AE%B0%E5%BD%95%EF%BC%88%E6%9C%AA%E5%AE%8C%EF%BC%89/20210226123042230.png" class="" title="在这里插入图片描述">  
<p><strong>轮廓检测</strong></p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br></pre></td><td class="code"><pre><span class="line">img = cv2.imread(<span class="string">&#x27;imgs/mountain.png&#x27;</span>)</span><br><span class="line">gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)</span><br><span class="line">ret, binary = cv2.threshold(gray,<span class="number">176</span>,<span class="number">255</span>,cv2.THRESH_BINARY)</span><br><span class="line"></span><br><span class="line"><span class="comment">#轮廓检测</span></span><br><span class="line"><span class="comment">#contours,hierarchy = cv2.findContours(image, mode, method[, contours[, hierarchy[, offset ]]])  </span></span><br><span class="line"><span class="string">&#x27;&#x27;&#x27;</span></span><br><span class="line"><span class="string">参数：</span></span><br><span class="line"><span class="string">    mode </span></span><br><span class="line"><span class="string">        cv2.RETR_EXTERNAL 表示只检测外轮廓</span></span><br><span class="line"><span class="string">        cv2.RETR_LIST 检测的轮廓不建立等级关系</span></span><br><span class="line"><span class="string">        cv2.RETR_CCOMP 建立两个等级的轮廓，上面的一层为外边界，里面的一层为内孔的边界信息。如果内孔内还有一个连通物体，这个物体的边界也在顶层。</span></span><br><span class="line"><span class="string">        cv2.RETR_TREE 建立一个等级树结构的轮廓。</span></span><br><span class="line"><span class="string">    method</span></span><br><span class="line"><span class="string">        cv2.CHAIN_APPROX_NONE 存储所有的轮廓点，相邻的两个点的像素位置差不超过1，即max（abs（x1-x2），abs（y2-y1））==1</span></span><br><span class="line"><span class="string">        cv2.CHAIN_APPROX_SIMPLE 压缩水平方向，垂直方向，对角线方向的元素，只保留该方向的终点坐标，例如一个矩形轮廓只需4个点来保存轮廓信息</span></span><br><span class="line"><span class="string">        cv2.CHAIN_APPROX_TC89_L1，CV_CHAIN_APPROX_TC89_KCOS 使用teh-Chinl chain 近似算法</span></span><br><span class="line"><span class="string">返回值：</span></span><br><span class="line"><span class="string">    contours   是列表，其中每个元素都是图像中的一个轮廓，用numpy中的ndarray表示</span></span><br><span class="line"><span class="string">    hierarchy  是一个ndarray，其中的元素个数和轮廓个数相同，每个轮廓contours[i]对应4个hierarchy元素hierarchy[i][0] ~hierarchy[i][3]，</span></span><br><span class="line"><span class="string">               分别表示后一个轮廓、前一个轮廓、父轮廓、内嵌轮廓的索引编号，如果没有对应项，则该值为负数。</span></span><br><span class="line"><span class="string">&#x27;&#x27;&#x27;</span></span><br><span class="line">contour, hierarchy= cv2.findContours(binary,cv2.RETR_TREE,cv2.CHAIN_APPROX_NONE)</span><br><span class="line"></span><br><span class="line"><span class="comment">#画轮廓</span></span><br><span class="line"><span class="comment">#cv2.drawContours(image, contours, contourIdx, color[, thickness[, lineType[, hierarchy[, maxLevel[, offset ]]]]])</span></span><br><span class="line"><span class="string">&#x27;&#x27;&#x27;</span></span><br><span class="line"><span class="string">参数：</span></span><br><span class="line"><span class="string">    image 绘制轮廓的图片 注意函数会在image原图上直接作修改</span></span><br><span class="line"><span class="string">    contours 轮廓</span></span><br><span class="line"><span class="string">    contourIdx 要绘制的轮廓的编号，-1为绘制所有</span></span><br><span class="line"><span class="string">    color 绘制轮廓用的颜色</span></span><br><span class="line"><span class="string">    thickness 线条宽度</span></span><br><span class="line"><span class="string">&#x27;&#x27;&#x27;</span></span><br><span class="line">con = cv2.drawContours(img.copy(),contour,<span class="number">0</span>,(<span class="number">255</span>,<span class="number">0</span>,<span class="number">255</span>),<span class="number">4</span>)</span><br><span class="line">cv2.imshow(<span class="string">&#x27;ss&#x27;</span>,con)</span><br><span class="line">cv2.waitKey(<span class="number">0</span>)</span><br><span class="line">cv2.destroyAllWindows()</span><br><span class="line"></span><br></pre></td></tr></table></figure>
<p><strong>轮廓近似</strong></p>
   <figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#轮廓近似</span></span><br><span class="line">x = contour[<span class="number">0</span>]</span><br><span class="line">epsilon1 = <span class="number">0.05</span>*cv2.arcLength(x,<span class="literal">True</span>)  <span class="comment">#计算轮廓周长</span></span><br><span class="line">epsilon2 = <span class="number">0.1</span>*cv2.arcLength(x,<span class="literal">True</span>)   <span class="comment">#计算轮廓周长</span></span><br><span class="line"><span class="string">&#x27;&#x27;&#x27;</span></span><br><span class="line"><span class="string">cv2.approxPolyDP()中给出一个轮廓contour和阈值epsilon</span></span><br><span class="line"><span class="string">&#x27;&#x27;&#x27;</span></span><br><span class="line">approx1 = cv2.approxPolyDP(x,epsilon1,<span class="literal">True</span>)</span><br><span class="line">approx2 = cv2.approxPolyDP(x,epsilon2,<span class="literal">True</span>)</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="string">&#x27;&#x27;&#x27;</span></span><br><span class="line"><span class="string">实测第二个参数形如approx结果只能在图上点点，若形如[approx]结果为点加连线</span></span><br><span class="line"><span class="string">&#x27;&#x27;&#x27;</span></span><br><span class="line">con = cv2.drawContours(img.copy(),[approx1],-<span class="number">1</span>,(<span class="number">255</span>,<span class="number">0</span>,<span class="number">255</span>),<span class="number">5</span>)</span><br><span class="line">cv2.imshow(<span class="string">&#x27;ss&#x27;</span>,con)</span><br><span class="line">cv2.waitKey(<span class="number">0</span>)</span><br><span class="line">cv2.destroyAllWindows()</span><br><span class="line">cv2.imwrite(<span class="string">&#x27;imgs_save/mountain+contour1.png&#x27;</span>,con)</span><br><span class="line">con = cv2.drawContours(img.copy(),[approx2],-<span class="number">1</span>,(<span class="number">255</span>,<span class="number">0</span>,<span class="number">255</span>),<span class="number">5</span>)</span><br><span class="line">cv2.imshow(<span class="string">&#x27;ss&#x27;</span>,con)</span><br><span class="line">cv2.waitKey(<span class="number">0</span>)</span><br><span class="line">cv2.destroyAllWindows()</span><br><span class="line">cv2.imwrite(<span class="string">&#x27;imgs_save/mountain+contour2.png&#x27;</span>,con)</span><br><span class="line"></span><br></pre></td></tr></table></figure>
<img src="/1444/11/11/%E3%80%90%E5%AD%A6%E4%B9%A0%E8%AE%B0%E5%BD%95%E3%80%91%E3%80%90python%E3%80%91%E3%80%90opencv%E3%80%91%E8%87%AA%E5%AD%A6%E7%AE%80%E8%A6%81%E8%AE%B0%E5%BD%95%EF%BC%88%E6%9C%AA%E5%AE%8C%EF%BC%89/20210226153513165.png" class="" title="在这里插入图片描述">  
<img src="/1444/11/11/%E3%80%90%E5%AD%A6%E4%B9%A0%E8%AE%B0%E5%BD%95%E3%80%91%E3%80%90python%E3%80%91%E3%80%90opencv%E3%80%91%E8%87%AA%E5%AD%A6%E7%AE%80%E8%A6%81%E8%AE%B0%E5%BD%95%EF%BC%88%E6%9C%AA%E5%AE%8C%EF%BC%89/20210226153520670.png" class="" title="在这里插入图片描述">  
<p>资料很多都是cpp的暂时不明白最后一个 参数是干嘛的，一下为True(左)和False(右)的对比</p>
<img src="/1444/11/11/%E3%80%90%E5%AD%A6%E4%B9%A0%E8%AE%B0%E5%BD%95%E3%80%91%E3%80%90python%E3%80%91%E3%80%90opencv%E3%80%91%E8%87%AA%E5%AD%A6%E7%AE%80%E8%A6%81%E8%AE%B0%E5%BD%95%EF%BC%88%E6%9C%AA%E5%AE%8C%EF%BC%89/20210304133649187.png" class="" title="在这里插入图片描述">
<h2 id="008-模板匹配"><a class="markdownIt-Anchor" href="#008-模板匹配"></a> 008 模板匹配</h2>
<p>参考资料：<br />
<a target="_blank" rel="noopener" href="http://www.opencv.org.cn/opencvdoc/2.3.2/html/doc/tutorials/imgproc/histograms/template_matching/template_matching.html">http://www.opencv.org.cn/opencvdoc/2.3.2/html/doc/tutorials/imgproc/histograms/template_matching/template_matching.html</a></p>
<p><a target="_blank" rel="noopener" href="https://www.cnblogs.com/ssyfj/p/9271883.html">https://www.cnblogs.com/ssyfj/p/9271883.html</a></p>
<p><a target="_blank" rel="noopener" href="https://www.cnblogs.com/jiyanjiao-702521/p/10471032.html">https://www.cnblogs.com/jiyanjiao-702521/p/10471032.html</a></p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br></pre></td><td class="code"><pre><span class="line">method = [cv2.TM_CCOEFF,cv2.TM_CCOEFF_NORMED, cv2.TM_CCORR, cv2.TM_CCORR_NORMED, cv2.TM_SQDIFF, cv2.TM_SQDIFF_NORMED]</span><br><span class="line">lst = []</span><br><span class="line">re = []</span><br><span class="line"></span><br><span class="line"><span class="comment">#获得match结果矩阵</span></span><br><span class="line"><span class="keyword">for</span> i <span class="keyword">in</span> <span class="built_in">range</span>(<span class="built_in">len</span>(method)):</span><br><span class="line">    match = cv2.matchTemplate(img,template,method[i])</span><br><span class="line">    lst.append(match)</span><br><span class="line"><span class="comment">#找到最优匹配位置并画方框</span></span><br><span class="line"><span class="keyword">for</span> i <span class="keyword">in</span> <span class="built_in">range</span>(<span class="built_in">len</span>(method)):</span><br><span class="line">    min_val,max_val,min_loc,max_loc = cv2.minMaxLoc(lst[i])</span><br><span class="line">    TL = min_loc <span class="keyword">if</span> method[i] <span class="keyword">in</span> [cv2.TM_SQDIFF, cv2.TM_SQDIFF_NORMED] <span class="keyword">else</span> max_loc</span><br><span class="line">    BR = TL[<span class="number">0</span>]+template.shape[<span class="number">1</span>] , TL[<span class="number">1</span>]+template.shape[<span class="number">0</span>]</span><br><span class="line">    tt = img.copy()</span><br><span class="line">    cv2.rectangle(tt,TL,BR,(<span class="number">0</span>,<span class="number">255</span>,<span class="number">0</span>),<span class="number">2</span>)</span><br><span class="line">    re.append(tt)</span><br><span class="line"></span><br><span class="line"><span class="comment">#储存</span></span><br><span class="line">fi = np.vstack(re)</span><br><span class="line">fi = cv2.resize(fi,(<span class="number">0</span>,<span class="number">0</span>),fx = <span class="number">0.45</span>, fy = <span class="number">0.45</span>)</span><br><span class="line">cv2.imwrite(<span class="string">&#x27;imgs_save/chess_rec+\&#x27;str(cnt)+\&#x27;.png&#x27;</span>,fi)</span><br></pre></td></tr></table></figure>
<p>模板</p>
<img src="/1444/11/11/%E3%80%90%E5%AD%A6%E4%B9%A0%E8%AE%B0%E5%BD%95%E3%80%91%E3%80%90python%E3%80%91%E3%80%90opencv%E3%80%91%E8%87%AA%E5%AD%A6%E7%AE%80%E8%A6%81%E8%AE%B0%E5%BD%95%EF%BC%88%E6%9C%AA%E5%AE%8C%EF%BC%89/20210226154317636.jpg" class="" title="在这里插入图片描述">  
<p>结果</p>
<img src="/1444/11/11/%E3%80%90%E5%AD%A6%E4%B9%A0%E8%AE%B0%E5%BD%95%E3%80%91%E3%80%90python%E3%80%91%E3%80%90opencv%E3%80%91%E8%87%AA%E5%AD%A6%E7%AE%80%E8%A6%81%E8%AE%B0%E5%BD%95%EF%BC%88%E6%9C%AA%E5%AE%8C%EF%BC%89/20210226154250532.png" class="" title="在这里插入图片描述">
<h2 id="009-直方图"><a class="markdownIt-Anchor" href="#009-直方图"></a> 009 直方图</h2>
<p><strong>获得直方图数据<br />
直方图均衡化</strong></p>
<p><strong>获得直方图数据</strong></p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#得到直方图数据</span></span><br><span class="line"><span class="comment">#cv2.calcHist(images, channels, mask, histSize, ranges[, hist[, accumulate ]])</span></span><br><span class="line"><span class="string">&#x27;&#x27;&#x27;</span></span><br><span class="line"><span class="string">imaes:输入的图像</span></span><br><span class="line"><span class="string">channels:选择图像的通道</span></span><br><span class="line"><span class="string">mask:掩膜，是一个大小和image一样的np数组，其中把需要处理的部分指定为1，不需要处理的部分指定为0，一般设置为None，表示处理整幅图像</span></span><br><span class="line"><span class="string">histSize:使用多少个bin(柱子)，一般为256</span></span><br><span class="line"><span class="string">ranges:像素值的范围，一般为[0,255]表示0~255</span></span><br><span class="line"><span class="string">后面两个参数基本不用管。</span></span><br><span class="line"><span class="string">注意，除了mask，其他四个参数都要带[]号</span></span><br><span class="line"><span class="string"></span></span><br><span class="line"><span class="string">返回值为hist，直方图；接着使用</span></span><br><span class="line"><span class="string">matplotlib.pyplot.plot(hist,color)进行绘制</span></span><br><span class="line"><span class="string">&#x27;&#x27;&#x27;</span></span><br><span class="line"></span><br><span class="line">gray = cv2.resize(cv2.imread(<span class="string">&#x27;imgs/InLab1.jpg&#x27;</span>,<span class="number">0</span>),(<span class="number">0</span>,<span class="number">0</span>),fx = <span class="number">0.2</span>,fy = <span class="number">0.2</span>)</span><br><span class="line">img = cv2.resize(cv2.imread(<span class="string">&#x27;imgs/InLab1.jpg&#x27;</span>),(<span class="number">0</span>,<span class="number">0</span>),fx = <span class="number">0.2</span>,fy = <span class="number">0.2</span>)</span><br><span class="line"></span><br><span class="line">hist = cv2.calcHist([gray],[<span class="number">0</span>],<span class="literal">None</span>,[<span class="number">256</span>],[<span class="number">0</span>,<span class="number">256</span>])</span><br><span class="line">plt.plot(hist)</span><br><span class="line">plt.savefig(<span class="string">&#x27;imgs_save/InLab1_0.2_zhifangtuGRAY.png&#x27;</span>)</span><br><span class="line"></span><br><span class="line">color = (<span class="string">&#x27;b&#x27;</span>,<span class="string">&#x27;g&#x27;</span>,<span class="string">&#x27;r&#x27;</span>)</span><br><span class="line"><span class="keyword">for</span> i,each <span class="keyword">in</span> <span class="built_in">enumerate</span>(color):</span><br><span class="line">    hist = cv2.calcHist([img],[i],<span class="literal">None</span>,[<span class="number">256</span>],[<span class="number">0</span>,<span class="number">256</span>])</span><br><span class="line">    plt.plot(hist,color = each)</span><br><span class="line">plt.savefig(<span class="string">&#x27;imgs_save/InLab1_0.2_zhifangtuRGB.png&#x27;</span>)</span><br><span class="line"></span><br></pre></td></tr></table></figure>
<img src="/1444/11/11/%E3%80%90%E5%AD%A6%E4%B9%A0%E8%AE%B0%E5%BD%95%E3%80%91%E3%80%90python%E3%80%91%E3%80%90opencv%E3%80%91%E8%87%AA%E5%AD%A6%E7%AE%80%E8%A6%81%E8%AE%B0%E5%BD%95%EF%BC%88%E6%9C%AA%E5%AE%8C%EF%BC%89/2021030415003013.png" class="" title="在这里插入图片描述">  
<img src="/1444/11/11/%E3%80%90%E5%AD%A6%E4%B9%A0%E8%AE%B0%E5%BD%95%E3%80%91%E3%80%90python%E3%80%91%E3%80%90opencv%E3%80%91%E8%87%AA%E5%AD%A6%E7%AE%80%E8%A6%81%E8%AE%B0%E5%BD%95%EF%BC%88%E6%9C%AA%E5%AE%8C%EF%BC%89/202103041500376.png" class="" title="在这里插入图片描述">  
<p><strong>直方图均衡化</strong><br />
原理（大概）:从小到大，像素依次变为像素的积累概率（这个像素以及比这个像素小的像素出现的总概率）*最大-最小？（255-0)<br />
1.全局均衡化</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#直方图均衡化</span></span><br><span class="line"><span class="comment">#cv2.equalizeHist(img)</span></span><br><span class="line"><span class="string">&#x27;&#x27;&#x27;</span></span><br><span class="line"><span class="string">要求是灰度图</span></span><br><span class="line"><span class="string">&#x27;&#x27;&#x27;</span></span><br><span class="line">equalized = cv2.equalizeHist(gray)</span><br><span class="line"><span class="comment">#both = np.hstack([gray,equalized])</span></span><br><span class="line">cv2.imshow(<span class="string">&#x27;asdf&#x27;</span>,both)</span><br><span class="line">cv2.waitKey(<span class="number">0</span>)</span><br><span class="line">cv2.destroyAllWindows()</span><br><span class="line"></span><br></pre></td></tr></table></figure>
<p>2.限制对比度自适应直方图均衡 CLAHE算法</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line"><span class="comment">#自适应均衡化 分块+调整让块与块之间看起来没有界限</span></span><br><span class="line"><span class="string">&#x27;&#x27;&#x27;</span></span><br><span class="line"><span class="string">clipLimit参数表示对比度的大小。</span></span><br><span class="line"><span class="string">tileGridSize参数表示每次处理块的大小 。</span></span><br><span class="line"><span class="string">&#x27;&#x27;&#x27;</span></span><br><span class="line">clahe = cv2.createCLAHE(clipLimit=<span class="number">2.0</span>, tileGridSize=(<span class="number">8</span>,<span class="number">8</span>))</span><br><span class="line">clahed = clahe.apply(gray)</span><br><span class="line"></span><br></pre></td></tr></table></figure>
<p>效果： 1 灰度图原图 . 2全局均衡化 3.CLAHE</p>
<img src="/1444/11/11/%E3%80%90%E5%AD%A6%E4%B9%A0%E8%AE%B0%E5%BD%95%E3%80%91%E3%80%90python%E3%80%91%E3%80%90opencv%E3%80%91%E8%87%AA%E5%AD%A6%E7%AE%80%E8%A6%81%E8%AE%B0%E5%BD%95%EF%BC%88%E6%9C%AA%E5%AE%8C%EF%BC%89/20210304150301662.png" class="" title="在这里插入图片描述">

      
    </div>
    <footer class="article-footer">
      <a data-url="http://example.com/1444/11/11/%E3%80%90%E5%AD%A6%E4%B9%A0%E8%AE%B0%E5%BD%95%E3%80%91%E3%80%90python%E3%80%91%E3%80%90opencv%E3%80%91%E8%87%AA%E5%AD%A6%E7%AE%80%E8%A6%81%E8%AE%B0%E5%BD%95%EF%BC%88%E6%9C%AA%E5%AE%8C%EF%BC%89/" data-id="cl2uhoech0029e4j3dsstcq7g" class="article-share-link">分享</a>
      
      
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/cv/" rel="tag">cv</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/python%E5%BA%93/" rel="tag">python库</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/%E5%9B%BE%E5%83%8F%E5%A4%84%E7%90%86/" rel="tag">图像处理</a></li></ul>

    </footer>
  </div>
  
</article>




  
    <article id="post-C语言程序（有一点pp）实现PVZ一代修改，探索记录 (随缘更新)" class="wow slideInRight article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/1111/11/11/C%E8%AF%AD%E8%A8%80%E7%A8%8B%E5%BA%8F%EF%BC%88%E6%9C%89%E4%B8%80%E7%82%B9pp%EF%BC%89%E5%AE%9E%E7%8E%B0PVZ%E4%B8%80%E4%BB%A3%E4%BF%AE%E6%94%B9%EF%BC%8C%E6%8E%A2%E7%B4%A2%E8%AE%B0%E5%BD%95%20(%E9%9A%8F%E7%BC%98%E6%9B%B4%E6%96%B0)/" class="article-date">
  <time class="post-time" datetime="1111-11-11T03:06:11.000Z" itemprop="datePublished">
    <span class="post-month">11月</span><br/>
    <span class="post-day">11</span>
  </time>
</a>
   
  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/1111/11/11/C%E8%AF%AD%E8%A8%80%E7%A8%8B%E5%BA%8F%EF%BC%88%E6%9C%89%E4%B8%80%E7%82%B9pp%EF%BC%89%E5%AE%9E%E7%8E%B0PVZ%E4%B8%80%E4%BB%A3%E4%BF%AE%E6%94%B9%EF%BC%8C%E6%8E%A2%E7%B4%A2%E8%AE%B0%E5%BD%95%20(%E9%9A%8F%E7%BC%98%E6%9B%B4%E6%96%B0)/">C语言程序（有一点pp）实现PVZ一代修改，探索记录 (随缘更新).md</a>
    </h1>
  

        <div>
          
  <div class="article-category">
    <a class="article-category-link" href="/categories/%E6%95%99%E7%BB%83%E6%88%91%E6%83%B3%E5%AD%A6%E6%8C%82%E8%BE%B9%E8%BA%B2%E7%89%9B/">教练我想学挂边躲牛</a>,<a class="article-category-link" href="/categories/%E6%95%99%E7%BB%83%E6%88%91%E6%83%B3%E5%AD%A6%E6%8C%82%E8%BE%B9%E8%BA%B2%E7%89%9B/%E9%80%86%E5%90%91/">逆向</a>
  </div>

          
              

          
        </div>
      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <h2 id="说明-2022-05-05"><a class="markdownIt-Anchor" href="#说明-2022-05-05"></a> 说明 - 2022-05-05</h2>
<p>本篇博客为本人原创, 原发布于CSDN, 在搭建个人博客后使用爬虫批量爬取并挂到个人博客, 出于一些技术原因博客未能完全还原到初始版本(而且我懒得修改), 在观看体验上会有一些瑕疵 ,若有需求会发布重制版总结性新博客。发布时间统一定为1111年11月11日。钦此。</p>
<h3 id="wscb-只用过ce"><a class="markdownIt-Anchor" href="#wscb-只用过ce"></a> wscb 只用过CE</h3>
<p>建议食用前先熟悉CE基本操作</p>
<h3 id="游戏版本"><a class="markdownIt-Anchor" href="#游戏版本"></a> 游戏版本</h3>
<p>Plants_Vs_Zombies_V1.0.0.1051_EN</p>
<h1 id="0找到pvz进程"><a class="markdownIt-Anchor" href="#0找到pvz进程"></a> 0.找到PVZ进程</h1>
<p><strong>这一步是之后对内存操作的基础</strong><br />
导入windows.h头文件， 我们就可以使用winAPI，于是我们可以根据窗口标题找到游戏进程。</p>
<h4 id="1找到pvz窗口的句柄hwnd类型"><a class="markdownIt-Anchor" href="#1找到pvz窗口的句柄hwnd类型"></a> 1.找到PVZ窗口的句柄(HWND类型)</h4>
<p>使用winAPI FindWindow， 下方代码展现了他的一种用法</p>
<h4 id="2找到pvz进程iddword类型"><a class="markdownIt-Anchor" href="#2找到pvz进程iddword类型"></a> 2.找到PVZ进程ID（DWORD类型）</h4>
<p>DWORD即无符号int<br />
使用API GetWindowThreadProcessId</p>
<h4 id="3找到进程句柄handle类型"><a class="markdownIt-Anchor" href="#3找到进程句柄handle类型"></a> 3.找到进程句柄（HANDLE类型）</h4>
<p>使用API OpenProcess</p>
<p>​</p>
<figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="function">HANDLE <span class="title">CatchPvzProcessByTitle</span><span class="params">(LPCTSTR ProcessTitleName)</span></span>&#123;</span><br><span class="line">    HWND hwnd = <span class="built_in">FindWindow</span>(<span class="literal">NULL</span>, ProcessTitleName);</span><br><span class="line">    DWORD processID = <span class="number">0</span>;</span><br><span class="line">    HANDLE PVZprocess = <span class="literal">NULL</span>;</span><br><span class="line">    <span class="built_in">GetWindowThreadProcessId</span>(hwnd, &amp;processID);</span><br><span class="line">    <span class="keyword">if</span>(!processID) <span class="keyword">return</span> <span class="literal">NULL</span>;</span><br><span class="line">    PVZprocess = <span class="built_in">OpenProcess</span>(PROCESS_ALL_ACCESS,FALSE,processID);</span><br><span class="line">    <span class="keyword">return</span> PVZprocess;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<h1 id="1修改阳光"><a class="markdownIt-Anchor" href="#1修改阳光"></a> 1.修改阳光</h1>
<h4 id="1找地址"><a class="markdownIt-Anchor" href="#1找地址"></a> 1.找地址</h4>
<p>使用CE精确数值搜索，可以轻易确定阳光地址<br />
<s>1.5 好的我们来寻找基址， 找基址的方法是直接莽(因为真不会找)， 然后就找到了！</s></p>
<h4 id="2找基址偏移"><a class="markdownIt-Anchor" href="#2找基址偏移"></a> 2.找基址+偏移</h4>
<p>找到阳光的基址和偏移， 发现是<br />
[ [ [ p o p c a p g a m e 1. e x e + 2 A 9 E C 0 ] + 768 ] + 5560 ]<br />
[[[popcapgame1.exe+2A9EC0] + 768] + 5560]<br />
[[[popcapgame1.exe+2A9EC0]+768]+5560]<br />
而pvz起始申请的地址固定是0x400000, 所以起始地址是62A9EC0</p>
<h4 id="3修改内存内容"><a class="markdownIt-Anchor" href="#3修改内存内容"></a> 3.修改内存内容</h4>
<p>我们可以调用两个winAPI来读写内存: 这里意识流地介绍一点用法， 具体建议自己去查，因为作者也不会</p>
<p>​</p>
<figure class="highlight plaintext"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line">WriteProcessMemory</span><br><span class="line">ReadProcessMemory</span><br><span class="line">参数：</span><br><span class="line">(pvz进程句柄，地址，新值/读取值保存地址，数据大小，NULL)</span><br><span class="line">返回值：</span><br><span class="line">bool类型， 读写失败会返回0</span><br></pre></td></tr></table></figure>
<p>先读地址，确定目标地址是否可以访问， 若成功读取，则修改之。<br />
（如果在选择游戏模式界面， 显然不能修改阳光值， 或者你的地址写错了，也无法修改，所以要先读，如果读取能成功，可以排除一部分问题）</p>
<h4 id="4没什么用的总结"><a class="markdownIt-Anchor" href="#4没什么用的总结"></a> 4.没什么用的总结</h4>
<p>若正确开始了一句游戏，找到了正确的阳光基址以及偏移量，正确调用修改内存的函数，便可以成功修改阳光数值。</p>
<h1 id="2-卡片无冷却"><a class="markdownIt-Anchor" href="#2-卡片无冷却"></a> 2. 卡片无冷却</h1>
<h4 id="一些探索"><a class="markdownIt-Anchor" href="#一些探索"></a> 一些探索</h4>
<h6 id="1"><a class="markdownIt-Anchor" href="#1"></a> 1.</h6>
<p>刚开始根据网上搜索的思路，以1字节为单位搜索，可以找到卡片是否在冷却的标志位，1代表准备就绪，0代表正在冷却。</p>
<h6 id="2"><a class="markdownIt-Anchor" href="#2"></a> 2.</h6>
<p>当你点击卡片，卡片就会变暗，这说明你点击卡片的同时，游戏修改了标志位的数值。</p>
<h6 id="3"><a class="markdownIt-Anchor" href="#3"></a> 3.</h6>
<p>生成反汇编代码，把mov [标志位地址], 00 的改为 01，这样点击卡片时，即标志位数值不变，即可让卡片无冷却。<br />
但这样会遇到一些问题， 这种操作只是“ <strong>不让卡片从就绪状态进入冷却状态”</strong> ， 如果你先使用卡片，在卡片冷却是修改代码，<br />
<strong>正在冷却的卡片是不会立刻准备就绪</strong> 的。</p>
<h6 id="4"><a class="markdownIt-Anchor" href="#4"></a> 4.</h6>
<p>遇到了另一个问题，在寻找基址的过程中，有一个中间步骤为[edi + 24], 但查找edi的值时无匹配项， 寻找基址无果。好在后来通过一个等价地址[eax</p>
<ul>
<li>ecx + 70]寻得，至于为何用到了两个寄存器做偏移， 当时未知， 之后探索出来了。</li>
</ul>
<h6 id="5"><a class="markdownIt-Anchor" href="#5"></a> 5.</h6>
<p>后来经过玄学+盯代码+猜+不严谨证明，习得了部分卡槽机制。</p>
<ul>
<li>
<p>每个卡槽都有一个“已经冷却了多长时间”的计时(即反汇编代码中的[edi + 24]), 这个计时会从冷却开始时增加。</p>
</li>
<li>
<p>每个卡槽都会根据所选植物不同有一个冷却时长(即反汇编代码中的[edi + 28])，当卡槽冷却计时达到了这个冷却时长，则冷却计时置0， 卡片进入就绪状态。</p>
</li>
<li>
<p>相邻卡槽冷却标志位地址做差，可以得到80(0x50)， 相邻卡槽冷却计时的地址做差，可以得到80(0x50)， 且对于同一卡槽，其冷却计时地址相对其冷却标志位地址的偏移为-36<br />
.</p>
</li>
<li>
<p>可以推测出，储存卡槽信息的是一系列连续的结构体，每个结构体占用0x50Byte的空间， 而经验证，双偏移中的[eax + ecx + 70]eax是50的倍数，即使第几个卡槽，可以直接通过ecx找到基址</p>
</li>
</ul>
<h4 id="卡片无冷却的修改方法"><a class="markdownIt-Anchor" href="#卡片无冷却的修改方法"></a> 卡片无冷却的修改方法</h4>
<p>找到了许多种，但未能深入理解代码</p>
<p>在反汇编代码中，<br />
冷却计时每次加1，通过不断的类似这样的循环，实现冷却恢复。只要冷却计时小于等于(jle)目标时间，循环就继续，游戏中的卡片冷却进度条也不断刷新。</p>
<blockquote>
<p>冷却计时+1<br />
mov, eax , 冷却计时<br />
cmp eax，目标时间<br />
把eax sub成0</p>
</blockquote>
<h6 id="1-修改反汇编代码固定地址0x487290处3个字节"><a class="markdownIt-Anchor" href="#1-修改反汇编代码固定地址0x487290处3个字节"></a> 1. 修改反汇编代码，固定地址0x487290处3个字节</h6>
<p>每次冷却计时+1， 把对应mov [xxx] 01改为 00，即冷却计时一直是0，可以实现卡片无冷却（貌似计时置0后循环就会跳出）。</p>
<h6 id="2-修改反汇编代码固定地址0x487296处1个字节"><a class="markdownIt-Anchor" href="#2-修改反汇编代码固定地址0x487296处1个字节"></a> 2. 修改反汇编代码，固定地址0x487296处1个字节</h6>
<p>把jle 改成ja(判大于)， 直接结束循环，之后卡片冷却标志位置1，实现无冷却</p>
<h6 id="3修改反汇编代码以及内存数据"><a class="markdownIt-Anchor" href="#3修改反汇编代码以及内存数据"></a> 3.修改反汇编代码以及内存数据</h6>
<p>先修改“使得卡片标志位变为00”的mov代码为01，使卡片不会从就绪状态进入冷却状态，然后通过时间计数+固定偏移36（0x28）修改所有卡槽的标志位为01，令正在冷却中的卡片刷新。</p>
<h6 id="没用的东西"><a class="markdownIt-Anchor" href="#没用的东西"></a> 没用的东西</h6>
<p>作者在CE中使用了这三种方法，但只选择方法2进行了代码实现</p>
<h1 id="3阳光自动收集"><a class="markdownIt-Anchor" href="#3阳光自动收集"></a> 3.阳光自动收集</h1>
<h5 id="0"><a class="markdownIt-Anchor" href="#0"></a> 0.</h5>
<p>进行4Byte搜索， 阳光会有一个标志判断是否被点击， 没点击时为0， 点击后为1。(不过点了阳光马上暂停好像找不出来，需要等一会)。</p>
<h5 id="1-2"><a class="markdownIt-Anchor" href="#1-2"></a> 1.</h5>
<p>找到阳光是否被点击的标志位后， 查看“什么访问了这个地址”， 发现一些有趣的数据,（节选）：</p>
<blockquote>
<p>若干个（cmp byte ptr [ebx+50],00 出现次数：非常非常多次）<br />
cmp byte ptr [ebx+50],00 出现次数：x (后跟jne)<br />
mov byte ptr [ebp+50],01 出现次数：x</p>
</blockquote>
<p>其中下方两行，每点击一次阳光，出现次数都加一。猜测时点击阳光时先判断阳光点击标志位是否=1（等价于标志位是否!=0），如果不为0，则跳转，<br />
否则进行第三行操作把标志位置1。</p>
<h5 id="2-2"><a class="markdownIt-Anchor" href="#2-2"></a> 2.</h5>
<p>然后联想到还有很多个出现非常多次的“cmp byte ptr [ebx+50],00”， 说明游戏会经常检验阳光是否被点击，<br />
那么猜想，检测到阳光被点击后，游戏应该会进行收集操作，很可能有一个cmp后会跟收集阳光操作。<br />
于是把其中一个“cmp byte ptr [ebx+50],00”后面的jne改为je（由 <strong>if 标志位!=0-阳光被点击</strong> 则跳转到收集操作 改为<br />
<strong>if 标志位==0-阳光不被点击</strong> 则跳转到收集操作）， 或者改成jmp也行</p>
<h5 id="3-2"><a class="markdownIt-Anchor" href="#3-2"></a> 3.</h5>
<p>所以， 只要把popcapgame1.exe+3158F位置的jne改为je，即可实现阳光的自动收集</p>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://example.com/1111/11/11/C%E8%AF%AD%E8%A8%80%E7%A8%8B%E5%BA%8F%EF%BC%88%E6%9C%89%E4%B8%80%E7%82%B9pp%EF%BC%89%E5%AE%9E%E7%8E%B0PVZ%E4%B8%80%E4%BB%A3%E4%BF%AE%E6%94%B9%EF%BC%8C%E6%8E%A2%E7%B4%A2%E8%AE%B0%E5%BD%95%20(%E9%9A%8F%E7%BC%98%E6%9B%B4%E6%96%B0)/" data-id="cl2uhoeb30001e4j3cnd9am51" class="article-share-link">分享</a>
      
      
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/OldBlog-Before20220505/" rel="tag">OldBlog(Before20220505)</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/%E5%86%85%E5%AD%98%E4%BF%AE%E6%94%B9/" rel="tag">内存修改</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/%E9%80%86%E5%90%91/" rel="tag">逆向</a></li></ul>

    </footer>
  </div>
  
</article>




  
    <article id="post-LCT" class="wow slideInRight article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/1111/11/11/LCT/" class="article-date">
  <time class="post-time" datetime="1111-11-11T03:06:11.000Z" itemprop="datePublished">
    <span class="post-month">11月</span><br/>
    <span class="post-day">11</span>
  </time>
</a>
   
  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/1111/11/11/LCT/">LCT</a>
    </h1>
  

        <div>
          
  <div class="article-category">
    <a class="article-category-link" href="/categories/%E7%AE%97%E6%B3%95/">算法</a>,<a class="article-category-link" href="/categories/%E7%AE%97%E6%B3%95/%E6%80%9D%E6%83%B3or%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84/">思想or数据结构</a>
  </div>

          
              

          
        </div>
      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <h2 id="说明-2022-05-05"><a class="markdownIt-Anchor" href="#说明-2022-05-05"></a> 说明 - 2022-05-05</h2>
<p>本篇博客为本人原创, 原发布于CSDN, 在搭建个人博客后使用爬虫批量爬取并挂到个人博客, 出于一些技术原因博客未能完全还原到初始版本(而且我懒得修改), 在观看体验上会有一些瑕疵 ,若有需求会发布重制版总结性新博客。发布时间统一定为1111年11月11日。钦此。</p>
<h2 id="p4219-bjoi2014大融合"><a class="markdownIt-Anchor" href="#p4219-bjoi2014大融合"></a> P4219 [BJOI2014]大融合</h2>
<figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;cstdio&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;algorithm&gt;</span></span></span><br><span class="line"><span class="type">int</span> n, m, op, a, b, x , y;</span><br><span class="line"><span class="type">const</span> <span class="type">int</span> N = <span class="number">3e5</span>+<span class="number">4</span>;</span><br><span class="line"><span class="type">int</span> top, sdk[N], son[N][<span class="number">2</span>], fa[N],rev[N], sxor[N], sxor2[N];</span><br><span class="line"><span class="function"><span class="keyword">inline</span> <span class="type">void</span> <span class="title">pushup</span><span class="params">(<span class="type">int</span> x)</span></span>&#123;</span><br><span class="line">    sxor[x] = sxor[son[x][<span class="number">0</span>]] + sxor[son[x][<span class="number">1</span>]] + sxor2[x] + <span class="number">1</span>;</span><br><span class="line">&#125;</span><br><span class="line"><span class="function"><span class="keyword">inline</span> <span class="type">void</span> <span class="title">hpushdown</span><span class="params">(<span class="type">int</span> x)</span></span>&#123;</span><br><span class="line">    <span class="keyword">if</span>(rev[x])&#123;</span><br><span class="line">        rev[son[x][<span class="number">0</span>]] ^= <span class="number">1</span>;</span><br><span class="line">        rev[son[x][<span class="number">1</span>]] ^= <span class="number">1</span>;</span><br><span class="line">        rev[x] ^= <span class="number">1</span>;</span><br><span class="line">        std::<span class="built_in">swap</span>(son[x][<span class="number">0</span>], son[x][<span class="number">1</span>]);</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"><span class="function"><span class="keyword">inline</span> <span class="type">bool</span> <span class="title">isroot</span><span class="params">(<span class="type">int</span> x)</span></span>&#123;</span><br><span class="line">    <span class="keyword">return</span> son[fa[x]][<span class="number">0</span>] != x &amp;&amp; son[fa[x]][<span class="number">1</span>] != x;</span><br><span class="line">&#125;</span><br><span class="line"><span class="function"><span class="keyword">inline</span> <span class="type">void</span> <span class="title">pushdown</span><span class="params">(<span class="type">int</span> x)</span></span>&#123;</span><br><span class="line">    <span class="keyword">if</span>(!<span class="built_in">isroot</span>(x)) <span class="built_in">pushdown</span>(fa[x]);</span><br><span class="line">    <span class="built_in">hpushdown</span>(x);</span><br><span class="line">&#125;</span><br><span class="line"><span class="function"><span class="type">void</span> <span class="title">rotate</span><span class="params">(<span class="type">int</span> x)</span></span>&#123;</span><br><span class="line">    <span class="type">int</span> y = fa[x], z = fa[y];</span><br><span class="line">    <span class="type">int</span> z2y = son[z][<span class="number">1</span>] == y, y2x = son[y][<span class="number">1</span>] == x;</span><br><span class="line">    <span class="keyword">if</span>(!<span class="built_in">isroot</span>(y)) son[z][z2y] = x;</span><br><span class="line">    fa[x] = z, fa[y] = x, fa[son[x][y2x ^ <span class="number">1</span>]] = y;</span><br><span class="line">    son[y][y2x] = son[x][y2x ^ <span class="number">1</span>], son[x][y2x ^ <span class="number">1</span>] = y;</span><br><span class="line">    <span class="built_in">pushup</span>(y); <span class="built_in">pushup</span>(x);</span><br><span class="line">&#125;</span><br><span class="line"><span class="function"><span class="type">void</span> <span class="title">splay</span><span class="params">(<span class="type">int</span> x)</span></span>&#123;</span><br><span class="line">    top = <span class="number">0</span>; sdk[++top] = x;</span><br><span class="line">    <span class="keyword">for</span>(<span class="type">int</span> i=x; !<span class="built_in">isroot</span>(i); i = fa[i]) sdk[++top] = fa[i];</span><br><span class="line">    <span class="keyword">for</span>(<span class="type">int</span> i=top; i; i--) <span class="built_in">pushdown</span>(sdk[i]);</span><br><span class="line">    <span class="keyword">while</span>(!<span class="built_in">isroot</span>(x))&#123;</span><br><span class="line">        <span class="type">int</span> y = fa[x], z = fa[y];</span><br><span class="line">        <span class="keyword">if</span>(!<span class="built_in">isroot</span>(y))&#123;</span><br><span class="line">            <span class="keyword">if</span>((son[y][<span class="number">0</span>] == x) ^ (son[z][<span class="number">0</span>] == y)) <span class="built_in">rotate</span>(x);</span><br><span class="line">            <span class="keyword">else</span> <span class="built_in">rotate</span>(y);</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="built_in">rotate</span>(x);</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"><span class="function"><span class="type">void</span> <span class="title">access</span><span class="params">(<span class="type">int</span> x)</span></span>&#123;</span><br><span class="line">    <span class="keyword">for</span>(<span class="type">int</span> t = <span class="number">0</span>; x; t = x, x = fa[x])&#123;</span><br><span class="line">        <span class="built_in">splay</span>(x);</span><br><span class="line">        sxor2[x] += sxor[son[x][<span class="number">1</span>]] - sxor[t];</span><br><span class="line">        son[x][<span class="number">1</span>] = t;</span><br><span class="line">        <span class="built_in">pushup</span>(x);</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"><span class="function"><span class="type">void</span> <span class="title">makeroot</span><span class="params">(<span class="type">int</span> x)</span></span>&#123;</span><br><span class="line">    <span class="built_in">access</span>(x); <span class="built_in">splay</span>(x); rev[x] ^= <span class="number">1</span>;</span><br><span class="line">&#125;</span><br><span class="line"><span class="function"><span class="type">int</span> <span class="title">find</span><span class="params">(<span class="type">int</span> x)</span></span>&#123;</span><br><span class="line">    <span class="built_in">access</span>(x); <span class="built_in">splay</span>(x);</span><br><span class="line">    <span class="keyword">while</span>(son[x][<span class="number">0</span>]) x = son[x][<span class="number">0</span>];</span><br><span class="line">    <span class="keyword">return</span> x;</span><br><span class="line">&#125;</span><br><span class="line"><span class="function"><span class="type">void</span> <span class="title">split</span><span class="params">(<span class="type">int</span> x, <span class="type">int</span> y)</span></span>&#123;</span><br><span class="line">    <span class="built_in">makeroot</span>(x); <span class="built_in">access</span>(y); <span class="built_in">splay</span>(y);</span><br><span class="line">&#125;</span><br><span class="line"><span class="function"><span class="type">void</span> <span class="title">cut</span><span class="params">(<span class="type">int</span> x, <span class="type">int</span> y)</span></span>&#123;</span><br><span class="line">    <span class="built_in">split</span>(x, y);</span><br><span class="line">    <span class="keyword">if</span>(son[y][<span class="number">0</span>] == x &amp;&amp; son[x][<span class="number">1</span>] == <span class="number">0</span>)&#123;</span><br><span class="line">        son[y][<span class="number">0</span>] = <span class="number">0</span>; </span><br><span class="line">        fa[x] = <span class="number">0</span>;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"><span class="function"><span class="type">void</span> <span class="title">link</span><span class="params">(<span class="type">int</span> x, <span class="type">int</span> y)</span></span>&#123;</span><br><span class="line">    <span class="built_in">makeroot</span>(x);</span><br><span class="line">    fa[x] = y;</span><br><span class="line">&#125;</span><br><span class="line"><span class="function"><span class="type">int</span> <span class="title">main</span><span class="params">()</span></span>&#123;</span><br><span class="line">    <span class="built_in">scanf</span>(<span class="string">&quot;%d%d&quot;</span>,&amp;n,&amp;m);</span><br><span class="line">    <span class="keyword">while</span>(m--)&#123;</span><br><span class="line">        <span class="built_in">scanf</span>(<span class="string">&quot;%*c%c%d%d&quot;</span>,&amp;op,&amp;x,&amp;y);</span><br><span class="line">        <span class="keyword">if</span>(op==<span class="string">&#x27;A&#x27;</span>)</span><br><span class="line">        &#123;</span><br><span class="line">            <span class="built_in">makeroot</span>(x);</span><br><span class="line">            <span class="built_in">makeroot</span>(y);</span><br><span class="line">            fa[x]=y;</span><br><span class="line">            sxor2[y]+=sxor[x];</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">if</span>(op==<span class="string">&#x27;Q&#x27;</span>)</span><br><span class="line">        &#123;</span><br><span class="line">            <span class="built_in">makeroot</span>(x); <span class="built_in">access</span>(y); <span class="built_in">splay</span>(y);</span><br><span class="line">            son[y][<span class="number">0</span>] = fa[x] = <span class="number">0</span>;</span><br><span class="line">            <span class="built_in">pushup</span>(x);</span><br><span class="line">            <span class="built_in">makeroot</span>(x); </span><br><span class="line">            <span class="built_in">makeroot</span>(y);</span><br><span class="line">            <span class="built_in">printf</span>(<span class="string">&quot;%lld\n&quot;</span>,(<span class="type">long</span> <span class="type">long</span>)(sxor[x]*sxor[y]));</span><br><span class="line">            <span class="built_in">makeroot</span>(x);</span><br><span class="line">            <span class="built_in">makeroot</span>(y);</span><br><span class="line">            fa[x]=y;</span><br><span class="line">            sxor2[y]+=sxor[x];</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://example.com/1111/11/11/LCT/" data-id="cl2uhoeb80003e4j313lb2djg" class="article-share-link">分享</a>
      
      
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/LCT/" rel="tag">LCT</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/OldBlog-Before20220505/" rel="tag">OldBlog(Before20220505)</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/Splay%E6%A0%91/" rel="tag">Splay树</a></li></ul>

    </footer>
  </div>
  
</article>




  
    <article id="post-Ubuntu下求生之路2Linux服务器搭建(官方战役，三方药抗)" class="wow slideInRight article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/1111/11/11/Ubuntu%E4%B8%8B%E6%B1%82%E7%94%9F%E4%B9%8B%E8%B7%AF2Linux%E6%9C%8D%E5%8A%A1%E5%99%A8%E6%90%AD%E5%BB%BA(%E5%AE%98%E6%96%B9%E6%88%98%E5%BD%B9%EF%BC%8C%E4%B8%89%E6%96%B9%E8%8D%AF%E6%8A%97)/" class="article-date">
  <time class="post-time" datetime="1111-11-11T03:06:11.000Z" itemprop="datePublished">
    <span class="post-month">11月</span><br/>
    <span class="post-day">11</span>
  </time>
</a>
   
  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/1111/11/11/Ubuntu%E4%B8%8B%E6%B1%82%E7%94%9F%E4%B9%8B%E8%B7%AF2Linux%E6%9C%8D%E5%8A%A1%E5%99%A8%E6%90%AD%E5%BB%BA(%E5%AE%98%E6%96%B9%E6%88%98%E5%BD%B9%EF%BC%8C%E4%B8%89%E6%96%B9%E8%8D%AF%E6%8A%97)/">Ubuntu下求生之路2Linux服务器搭建(官方战役，三方药抗).md</a>
    </h1>
  

        <div>
          
  <div class="article-category">
    <a class="article-category-link" href="/categories/%E6%95%99%E7%BB%83%E6%88%91%E6%83%B3%E5%AD%A6%E6%8C%82%E8%BE%B9%E8%BA%B2%E7%89%9B/">教练我想学挂边躲牛</a>,<a class="article-category-link" href="/categories/%E6%95%99%E7%BB%83%E6%88%91%E6%83%B3%E5%AD%A6%E6%8C%82%E8%BE%B9%E8%BA%B2%E7%89%9B/%E6%B8%B8%E6%88%8F/">游戏</a>,<a class="article-category-link" href="/categories/%E6%95%99%E7%BB%83%E6%88%91%E6%83%B3%E5%AD%A6%E6%8C%82%E8%BE%B9%E8%BA%B2%E7%89%9B/%E6%B8%B8%E6%88%8F/%E6%B1%82%E7%94%9F%E4%B9%8B%E8%B7%AF2/">求生之路2</a>
  </div>

          
              

          
        </div>
      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <h2 id="说明-2022-05-05"><a class="markdownIt-Anchor" href="#说明-2022-05-05"></a> 说明 - 2022-05-05</h2>
<p>本篇博客为本人原创, 原发布于CSDN, 在搭建个人博客后使用爬虫批量爬取并挂到个人博客, 出于一些技术原因博客未能完全还原到初始版本(而且我懒得修改), 在观看体验上会有一些瑕疵 ,若有需求会发布重制版总结性新博客。发布时间统一定为1111年11月11日。钦此。</p>
<h2 id="声明"><a class="markdownIt-Anchor" href="#声明"></a> 声明</h2>
<p>本文章仅为萌新探索搭建服务器后写的初级总结，有问题请指出。更深层次的内容请自己去研究Sir大佬或者其他人的资料。</p>
<h2 id="准备"><a class="markdownIt-Anchor" href="#准备"></a> 准备</h2>
<p>首先你需要有服务器或者云服务器，我是2核4gUbuntu系统，据说1核2g带求生之路服务器就没问题。<br />
我使用的Xshell远程连接服务器，使用Xftp从本地上传文件到服务器(不会的百度搜有教程)</p>
<h2 id="资料"><a class="markdownIt-Anchor" href="#资料"></a> 资料</h2>
<p>官方战役主要参考<a target="_blank" rel="noopener" href="https://blog.csdn.net/qq_31555445/article/details/105616307">https://blog.csdn.net/qq_31555445/article/details/105616307</a><br />
药抗插件资源和后期药抗搭建主要参考都是Sir大佬的&lt;<a target="_blank" rel="noopener" href="https://github.com/SirPlease/L4D2-Competitive-">https://github.com/SirPlease/L4D2-Competitive-</a><br />
Rework&gt;</p>
<h2 id="搭建过程"><a class="markdownIt-Anchor" href="#搭建过程"></a> 搭建过程</h2>
<p>这里就直接完全搬运Sir大佬的教程了</p>
<h4 id="1在服务器上安装以下环境或工具等"><a class="markdownIt-Anchor" href="#1在服务器上安装以下环境或工具等"></a> 1.在服务器上安装以下环境或工具等</h4>
<p>screen 是一个托盘工具， 开服后screen -r 可以看服务器状态</p>
<blockquote>
<p>dpkg --add-architecture i386 # enable multi-arch<br />
apt-get update &amp;&amp; apt-get upgrade<br />
apt-get install libc6:i386 # install base 32bit libraries<br />
apt-get install lib32z1<br />
apt-get install screen</p>
</blockquote>
<h4 id="2新建一个账户"><a class="markdownIt-Anchor" href="#2新建一个账户"></a> 2.新建一个账户</h4>
<p>其实直接用root用户也可以，新建一个用户可能安全一些。<br />
这里Sir大佬创建的账户名称是steam,名称可以自定义，但之后要把相应路径中的steam换成你自定义的名称。<br />
然后login登录。</p>
<blockquote>
<p>adduser steam<br />
adduser steam sudo<br />
login</p>
</blockquote>
<h4 id="3安装steamcmd并部署l4d2环境"><a class="markdownIt-Anchor" href="#3安装steamcmd并部署l4d2环境"></a> 3.安装steamcmd并部署L4D2环境</h4>
<p>下载steamcmd_linux.tar.gz</p>
<blockquote>
<p>wget <a target="_blank" rel="noopener" href="http://media.steampowered.com/installer/steamcmd_linux.tar.gz">http://media.steampowered.com/installer/steamcmd_linux.tar.gz</a></p>
</blockquote>
<p>把下载好的steamcmd_linux.tar.gz文件解压</p>
<blockquote>
<p>tar -xvzf steamcmd_linux.tar.gz</p>
</blockquote>
<p>进入Steam, 启动成功后你的屏幕上会有**Steam&gt;**标志</p>
<blockquote>
<p>./steamcmd.sh</p>
</blockquote>
<p>匿名登录,有一些游戏不支持匿名登陆下载，但显然L4D2可以</p>
<blockquote>
<p>login anonymous</p>
</blockquote>
<p>指定安装路径<br />
所以你文件的真实路径是/home/steam(这个是你的用户名)/Steam/steamapps/common/l4d2</p>
<blockquote>
<p>force_install_dir ./Steam/steamapps/common/l4d2</p>
</blockquote>
<p>安装求生之路</p>
<blockquote>
<p>app_update 222860 validate</p>
</blockquote>
<p>如果他提示你成功安装完成了，就可以退出了</p>
<blockquote>
<p>quit</p>
</blockquote>
<h2 id="配置文件"><a class="markdownIt-Anchor" href="#配置文件"></a> 配置文件</h2>
<p>首先需要先获取Sir大佬在Github上发布的资源，我在上面放过连接了，不会从Github下载东西的自行百度。<br />
。</p>
<h4 id="srcds1文件"><a class="markdownIt-Anchor" href="#srcds1文件"></a> srcds1文件</h4>
<p>在Sir大佬发布的资源中，这个文件的路径为：L4D2-Competitive-Rework-master\Dedicated Server Install<br />
Guide。<br />
。<br />
第四行，改成自己的账户名</p>
<blockquote>
<p>SRCDS_USER=“steam”</p>
</blockquote>
<p>第10行 ，/home后面第一个小写的steam，改成你的账户名</p>
<blockquote>
<p>DIR=/home/steam/Steam/steamapps/common/l4d2</p>
</blockquote>
<p>第37行，改成你自己服务器的IP</p>
<blockquote>
<p>IP=1.3.3.7</p>
</blockquote>
<p>第40行，把-ip $IP删掉。Sir大佬的教程是没有这一步的，但是我不删掉的时候没法正常开服。</p>
<blockquote>
<p>PARAMS=&quot;-game left4dead2 -ip $IP -port  P O R T + s v c l o c k c o r r e c<br />
t i o n m s e c s 25 − t i m e o u t 10 − t i c k r a t e 100 + m a p c 1 m<br />
1 h o t e l − m a x p l a y e r s 32 + s e r v e r c f g f i l e s e r v e<br />
r PORT +sv_clockcorrection_msecs 25 -timeout 10 -tickrate 100 +map<br />
c1m1_hotel -maxplayers 32 +servercfgfile server<br />
PORT+svc​lockcorrectionm​secs25−timeout10−tickrate100+mapc1m1h​otel−maxplayers32+servercfgfileserverSVNUM.cfg&quot;</p>
</blockquote>
<p>然后你就可以把这个scrds1文件放到这里（这是一个绝对路径）<br />
这个文件应是个启动脚本，至于为什么要放到这里，放到别处行不行，我没有尝试。</p>
<blockquote>
<p>/etc/init.d</p>
</blockquote>
<h4 id="servecfg文件"><a class="markdownIt-Anchor" href="#servecfg文件"></a> serve.cfg文件</h4>
<p>这个文件主要是配置游戏里的一些参数。<br />
第6行是你的服务器名。</p>
<blockquote>
<p>hostname “xxxxxxxxxxxx”</p>
</blockquote>
<p>第11行意思是把你的服务器设置为私有（也就是只有加入特定steam组的人才可以搜索到，不过服务器进人后好像路人也能匹配进来）</p>
<blockquote>
<p>sv_steamgroup_exclusive “1”</p>
</blockquote>
<p>而第九行是服务器所属的steam组号</p>
<blockquote>
<p>sv_steamgroup “xxxxxxxxx”</p>
</blockquote>
<p>然后你需要 <strong>把这个文件改名为serve1.cfg</strong> 因为Sir大佬就是这么设置的（他考虑了开很多服，而这篇文章讨论开一个服）</p>
<h4 id="进服后公告栏上显示的内容对应的文件"><a class="markdownIt-Anchor" href="#进服后公告栏上显示的内容对应的文件"></a> 进服后公告栏上显示的内容对应的文件</h4>
<p>进入服务器后，服务器提供者对应host.txt，下方信息对应motd.txt<br />
!match 进入药抗后 ，服务器提供者对应myhost.txt，下方信息对应mymotd.txt<br />
你可以自由编辑</p>
<h4 id="在服务器复制和替换文件"><a class="markdownIt-Anchor" href="#在服务器复制和替换文件"></a> 在服务器复制和替换文件</h4>
<p>直接到home/steam（你的账户名）/Steam/steamapps/common/l4d2/left4dead2/把修改后的Sir大佬的资源全复制进去就行了。<br />
我是现在本地windows修改了文件传上去的。（不会传的搜索Xshell上传文件到服务器）</p>
<h2 id="启动服务器"><a class="markdownIt-Anchor" href="#启动服务器"></a> 启动服务器</h2>
<p>先给srcds1文件加上可执行权限</p>
<blockquote>
<p>sudo chmod +x /etc/init.d/srcds1</p>
</blockquote>
<p>以下三种操作分别是重启服务器，启动服务器，停止服务器，分不清哪个是哪个的别开服务器了。</p>
<blockquote>
<p>/etc/init.d/srcds1 restart<br />
/etc/init.d/srcds1 start<br />
/etc/init.d/srcds1 stop</p>
</blockquote>
<h6 id="某些问题的解决方案"><a class="markdownIt-Anchor" href="#某些问题的解决方案"></a> 某些问题的解决方案</h6>
<p>这里有点记不清楚是哪个文件了,好像是srcds1这个脚本文件。<br />
开服时遇到了这个错误</p>
<blockquote>
<p>-bash: xxx: /bin/sh^M: bad interpreter: No such file or directory</p>
</blockquote>
<p>由于我现在windows编辑文件又上传到服务器，一个文件用vi编辑器打开后，输入</p>
<blockquote>
<p>:set ff</p>
</blockquote>
<p>显示的是fileformat=dos，而正常应该是fileformat=unix，所以直接进行修改</p>
<blockquote>
<p>set ff=unix</p>
</blockquote>
<p>然后使用上述命令就可以开服了。</p>
<h4 id="其他"><a class="markdownIt-Anchor" href="#其他"></a> 其他</h4>
<h6 id="关于托盘程序"><a class="markdownIt-Anchor" href="#关于托盘程序"></a> 关于托盘程序</h6>
<p>开服后登录你的新账户是可以看你的服务器状态的</p>
<blockquote>
<p>screen -r</p>
</blockquote>
<p>进入之后如果你这样按会关服</p>
<blockquote>
<p>Ctrl + C</p>
</blockquote>
<p>如果你想退出来这样按</p>
<blockquote>
<p>Ctrl + A 然后 Ctrl + D</p>
</blockquote>
<h6 id="你可以简化你开服的敲码量"><a class="markdownIt-Anchor" href="#你可以简化你开服的敲码量"></a> 你可以简化你开服的敲码量</h6>
<p>比如你可以在某个顺手的目录写个脚本</p>
<blockquote>
<p>vi <a target="_blank" rel="noopener" href="http://st.sh">st.sh</a></p>
</blockquote>
<blockquote>
<p>if [ $1 = “start” ]<br />
then<br />
/etc/init.d/srcds1 “start”<br />
elif [ $1 = “stop” ]<br />
then<br />
/etc/init.d/srcds1 “stop”<br />
elif [ $1 = “restart” ]<br />
then<br />
/etc/init.d/srcds1 “restart”<br />
else<br />
echo “Unknow command. arg should be [start/stop/restart]”<br />
fi</p>
</blockquote>
<p>然后就可以直接</p>
<blockquote>
<p>./st.sh start</p>
</blockquote>
<h2 id="关于游戏中的一些参数"><a class="markdownIt-Anchor" href="#关于游戏中的一些参数"></a> 关于游戏中的一些参数</h2>
<p>吹牛逼+讲故事</p>
<blockquote>
<p>问题解决了，说一下解决过程吧，可能造福以后遇到类似问题的人。<br />
没有大佬解答<br />
于是自己开始玄学（我下的插件有很多版本，promod（好像是这个名字，太菜了没印象），zonemod2.1，zonemod1.9，apexmod啥的，我只修改了zonemod2.1。）<br />
.<br />
.</p>
<p>具体思路是暴力查找文件，ctrl+f搜索诸如bot、infect、ghost等关键词，最后在\cfg\cfgogl\zonemod\shared_cvars.cfg的文件中找到了confogl_addcvar<br />
confogl_blockinfectedbots &quot;0&quot;和confogl_addcvar director_allow_infected_bots<br />
“0”，遂把它们全改成1<br />
。这时候进服务器可以看到字幕上出现了bommer的响声，linux服务器上也出现了含有jockey一堆英文，但跑了半张图都没见到特感，白高兴一场。于是怀疑还需要改其他的地方，就继续重新搜索了一遍，反而确定了跟特感有关的大概率就是这个文件。<br />
.<br />
.<br />
回过头来仔细看，blockinfectedbots是“阻碍特感电脑”的意思（英语太渣一开始看的头皮发麻就没有仔细看），所以猜测可能是<br />
director_allow_infected_bots设为1后导演系统允许特感刷新，但是由于blockinfectedbots把特感的刷新阻塞了，于是把confogl_addcvar<br />
director_allow_infected_bots 改回0 “0”，进入服务器发现ai特感刷新，被牛+口水一顿乱锤，但是非常开心。<br />
.<br />
.</p>
<p>总结 ： \cfg\cfgogl\zonemod\shared_cvars.cfg文件 ，把这玩意改成1就行了 confogl_addcvar<br />
director_allow_infected_bots “0”</p>
</blockquote>
<p>人话：<br />
这里我只改了ZoneMod v2.1插件的一些配置。<br />
许多参数都写在这个文件里 \cfg\cfgogl\zonemod\shared_cvars.cfg<br />
我列举我找到且用到的几个：<br />
。<br />
限制连推的次数，下面代码表示连推10次进入冷却。而冷却时间是递增的，在15次之后达到最大值。</p>
<blockquote>
<p>confogl_addcvar z_gun_swing_vs_min_penalty 10<br />
confogl_addcvar z_gun_swing_vs_max_penalty 15</p>
</blockquote>
<p>阻碍ai特感刷新</p>
<blockquote>
<p>confogl_addcvar confogl_blockinfectedbots “0”</p>
</blockquote>
<p>导演系统允许ai特感刷新</p>
<blockquote>
<p>confogl_addcvar director_allow_infected_bots “1”</p>
</blockquote>
<h2 id="关于服务器管理员"><a class="markdownIt-Anchor" href="#关于服务器管理员"></a> 关于服务器管理员</h2>
<p>这里我直接从网上找资料抄作业，没有深究。<br />
。<br />
先在服务器中找到文件addons\sourcemod\configs\core.cfg打开。找到第55行。这里的_password可以随便取名，可能是服务器的一个变量，假设我们把它改成<br />
_aaaa（记好了后面要考）</p>
<blockquote>
<p>“PassInfoVar” “_password”</p>
</blockquote>
<p>然后打开文件addons\sourcemod\configs\admins_simple.ini，拉到最下面加入以下内容，就可以把相应的名称设置为管理员名称</p>
<blockquote>
<p>“名称1” “99:z” “密码1”<br />
“名称2” “99:z” “密码2”</p>
</blockquote>
<p>名称1可以设置为你的steam用户名。<br />
在连接服务器之前，你需要在控制台输入以下代码来修改一些信息，否则你用管理员名称登录，服务器检测到你密码不对会拒绝你进入。<br />
<strong>密码要填写特定管理员名对应的密码</strong></p>
<blockquote>
<p>setinfo “_aaaa” “密码”</p>
</blockquote>
<p>此外，如果有人尝试在游戏中通过setinfo name &quot;xxx&quot;改名刚好改成了管理员名，也会被服务器直接T掉，除非他提前修改了信息</p>
<blockquote>
<p>setinfo “_aaaa” “他改成的管理员名称对应的密码”</p>
</blockquote>
<p>只要你使用管理员名称，就有管理员权限。如果你把名称改成了别的，就没有管理员权限。</p>
<h2 id="目前尚未解决的问题"><a class="markdownIt-Anchor" href="#目前尚未解决的问题"></a> 目前尚未解决的问题</h2>
<ol>
<li>ai生还吃药不加血，没解决，有大佬会的话私信或者评论帮一下忙呗。</li>
</ol>
<h2 id="关于游戏更新"><a class="markdownIt-Anchor" href="#关于游戏更新"></a> 关于游戏更新</h2>
<p>游戏更新后服务器是没法正常进入的(你可以尝试强行降低游戏版本，但估计不能正常游戏)，所以要在服务器更新游戏版本。</p>
<blockquote>
<p>./steamcmd.sh<br />
login anonymous<br />
app_update 222860 validate</p>
</blockquote>
<p>如果开了插件服务器，则需要等作者更新发布之后，你下载下来在服务器更新</p>
<h2 id="文章历史版本"><a class="markdownIt-Anchor" href="#文章历史版本"></a> 文章历史版本</h2>
<p>先堆一点东西占个坑，日后补完</p>
<p>资源和主要参考都是Sir大佬的<a target="_blank" rel="noopener" href="https://github.com/SirPlease/L4D2-Competitive-Rework">https://github.com/SirPlease/L4D2-Competitive-Rework</a></p>
<p>zonemod v2.1 打开ai特感总结：</p>
<blockquote>
<p>问题解决了，说一下解决过程吧，可能造福以后遇到类似问题的人。<br />
没有大佬解答<br />
于是自己开始玄学（我下的插件有很多版本，promod（好像是这个名字，太菜了没印象），zonemod2.1，zonemod1.9，apexmod啥的，我只修改了zonemod2.1。）<br />
.<br />
.</p>
<p>具体思路是暴力查找文件，ctrl+f搜索诸如bot、infect、ghost等关键词，最后在\cfg\cfgogl\zonemod\shared_cvars.cfg的文件中找到了confogl_addcvar<br />
confogl_blockinfectedbots &quot;0&quot;和confogl_addcvar director_allow_infected_bots<br />
“0”，遂把它们全改成1<br />
。这时候进服务器可以看到字幕上出现了bommer的响声，linux服务器上也出现了含有jockey一堆英文，但跑了半张图都没见到特感，白高兴一场。于是怀疑还需要改其他的地方，就继续重新搜索了一遍，反而确定了跟特感有关的大概率就是这个文件。<br />
.<br />
.<br />
回过头来仔细看，blockinfectedbots是“阻碍特感电脑”的意思（英语太渣一开始看的头皮发麻就没有仔细看），所以猜测可能是<br />
director_allow_infected_bots设为1后导演系统允许特感刷新，但是由于blockinfectedbots把特感的刷新阻塞了，于是把confogl_addcvar<br />
director_allow_infected_bots 改回0 “0”，进入服务器发现ai特感刷新，被牛+口水一顿乱锤，但是非常开心。<br />
.<br />
.</p>
<p>总结 ： \cfg\cfgogl\zonemod\shared_cvars.cfg文件 ，把这玩意改成1就行了 confogl_addcvar<br />
director_allow_infected_bots “0”</p>
</blockquote>
<h2 id="完结撒花"><a class="markdownIt-Anchor" href="#完结撒花"></a> 完结撒花</h2>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://example.com/1111/11/11/Ubuntu%E4%B8%8B%E6%B1%82%E7%94%9F%E4%B9%8B%E8%B7%AF2Linux%E6%9C%8D%E5%8A%A1%E5%99%A8%E6%90%AD%E5%BB%BA(%E5%AE%98%E6%96%B9%E6%88%98%E5%BD%B9%EF%BC%8C%E4%B8%89%E6%96%B9%E8%8D%AF%E6%8A%97)/" data-id="cl2uhoebb0006e4j39kcjcxp9" class="article-share-link">分享</a>
      
      
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/OldBlog-Before20220505/" rel="tag">OldBlog(Before20220505)</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/linux/" rel="tag">linux</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/%E6%9C%8D%E5%8A%A1%E5%99%A8/" rel="tag">服务器</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/%E6%B8%B8%E6%88%8F/" rel="tag">游戏</a></li></ul>

    </footer>
  </div>
  
</article>




  
    <article id="post-Splay" class="wow slideInRight article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/1111/11/11/Splay/" class="article-date">
  <time class="post-time" datetime="1111-11-11T03:06:11.000Z" itemprop="datePublished">
    <span class="post-month">11月</span><br/>
    <span class="post-day">11</span>
  </time>
</a>
   
  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/1111/11/11/Splay/">Splay.md</a>
    </h1>
  

        <div>
          
  <div class="article-category">
    <a class="article-category-link" href="/categories/%E7%AE%97%E6%B3%95/">算法</a>,<a class="article-category-link" href="/categories/%E7%AE%97%E6%B3%95/%E6%80%9D%E6%83%B3or%E6%95%B0%E6%8D%AE%E7%BB%93%E6%9E%84/">思想or数据结构</a>
  </div>

          
              

          
        </div>
      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <h2 id="说明-2022-05-05"><a class="markdownIt-Anchor" href="#说明-2022-05-05"></a> 说明 - 2022-05-05</h2>
<p>本篇博客为本人原创, 原发布于CSDN, 在搭建个人博客后使用爬虫批量爬取并挂到个人博客, 出于一些技术原因博客未能完全还原到初始版本(而且我懒得修改), 在观看体验上会有一些瑕疵 ,若有需求会发布重制版总结性新博客。发布时间统一定为1111年11月11日。钦此。</p>
<p><a target="_blank" rel="noopener" href="http://luogu.com.cn">luogu.com.cn</a> P3391 文艺平衡树</p>
<p>​</p>
<figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;cstdio&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;algorithm&gt;</span></span></span><br><span class="line"><span class="type">const</span> <span class="type">int</span> N = <span class="number">100005</span>;</span><br><span class="line"><span class="type">int</span> n, m, rt, qx, qy;</span><br><span class="line"><span class="keyword">struct</span> <span class="title class_">SplayNode</span>&#123;</span><br><span class="line">    <span class="type">int</span> fa, son[<span class="number">2</span>], size, rev, rt;</span><br><span class="line">&#125;snode[N];</span><br><span class="line"><span class="function"><span class="keyword">inline</span> <span class="type">void</span> <span class="title">pushup</span><span class="params">(<span class="type">int</span> x)</span></span>&#123;</span><br><span class="line">    <span class="type">int</span> son0 = snode[x].son[<span class="number">0</span>], son1 = snode[x].son[<span class="number">1</span>];</span><br><span class="line">    snode[x].size = snode[son0].size + snode[son1].size + <span class="number">1</span>;</span><br><span class="line">&#125;</span><br><span class="line"><span class="function"><span class="keyword">inline</span> <span class="type">void</span> <span class="title">pushdown</span><span class="params">(<span class="type">int</span> x)</span></span>&#123;</span><br><span class="line">    <span class="keyword">if</span>(snode[x].rev)&#123;</span><br><span class="line">        std::<span class="built_in">swap</span>(snode[x].son[<span class="number">0</span>], snode[x].son[<span class="number">1</span>]);</span><br><span class="line">        <span class="type">int</span> son0 = snode[x].son[<span class="number">0</span>], son1 = snode[x].son[<span class="number">1</span>];</span><br><span class="line">        snode[son0].rev ^= <span class="number">1</span>;</span><br><span class="line">        snode[son1].rev ^= <span class="number">1</span>;</span><br><span class="line">        snode[x].rev = <span class="number">0</span>;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"><span class="function"><span class="type">void</span> <span class="title">rotate</span><span class="params">(<span class="type">int</span> x, <span class="type">int</span> &amp;k)</span></span>&#123;</span><br><span class="line">    <span class="type">int</span> y = snode[x].fa, z = snode[y].fa;</span><br><span class="line">    <span class="type">int</span> y2x = snode[y].son[<span class="number">1</span>] == x, z2y = snode[z].son[<span class="number">1</span>] == y;</span><br><span class="line">    <span class="keyword">if</span>(y == k) k = x; <span class="keyword">else</span> snode[z].son[z2y] = x;</span><br><span class="line">    snode[y].son[y2x] = snode[x].son[y2x^<span class="number">1</span>];</span><br><span class="line">    snode[snode[y].son[y2x]].fa = y;</span><br><span class="line">    snode[x].son[y2x^<span class="number">1</span>] = y;</span><br><span class="line">    snode[y].fa = x, snode[x].fa = z;</span><br><span class="line">    <span class="built_in">pushup</span>(x), <span class="built_in">pushup</span>(y);</span><br><span class="line">&#125;</span><br><span class="line"><span class="function"><span class="type">void</span> <span class="title">splay</span><span class="params">(<span class="type">int</span> x, <span class="type">int</span> &amp;k)</span></span>&#123;</span><br><span class="line">    <span class="keyword">while</span>(x != k)&#123;</span><br><span class="line">        <span class="type">int</span> y = snode[x].fa, z = snode[y].fa;</span><br><span class="line">        <span class="keyword">if</span>(y != k)&#123;</span><br><span class="line">            <span class="keyword">if</span>((snode[y].son[<span class="number">1</span>] == x) ^ (snode[z].son[<span class="number">1</span>] == y)) <span class="built_in">rotate</span>(x, k);</span><br><span class="line">            <span class="keyword">else</span> <span class="built_in">rotate</span>(y, k);</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="built_in">rotate</span>(x, k);</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"><span class="function"><span class="type">int</span> <span class="title">find</span><span class="params">(<span class="type">int</span> x, <span class="type">int</span> k)</span></span>&#123;</span><br><span class="line">    <span class="built_in">pushdown</span>(x);</span><br><span class="line">    <span class="type">int</span> sz = snode[snode[x].son[<span class="number">0</span>]].size;</span><br><span class="line">    <span class="keyword">if</span>(k == sz + <span class="number">1</span>) <span class="keyword">return</span> x;</span><br><span class="line">    <span class="keyword">if</span>(k &lt;= sz) <span class="keyword">return</span> <span class="built_in">find</span>(snode[x].son[<span class="number">0</span>],k);</span><br><span class="line">    <span class="keyword">else</span> <span class="keyword">return</span> <span class="built_in">find</span>(snode[x].son[<span class="number">1</span>], k - sz - <span class="number">1</span>);</span><br><span class="line">&#125;</span><br><span class="line"><span class="function"><span class="type">void</span> <span class="title">rev</span><span class="params">(<span class="type">int</span> l, <span class="type">int</span> r)</span></span>&#123;</span><br><span class="line">    <span class="type">int</span> x = <span class="built_in">find</span>(rt, l), y = <span class="built_in">find</span>(rt, r);</span><br><span class="line">    <span class="built_in">splay</span>(x, rt);</span><br><span class="line">    <span class="built_in">splay</span>(y, snode[x].son[<span class="number">1</span>]);</span><br><span class="line">    <span class="type">int</span> z = snode[y].son[<span class="number">0</span>];</span><br><span class="line">    snode[z].rev ^= <span class="number">1</span>;</span><br><span class="line">&#125;</span><br><span class="line"><span class="function"><span class="type">void</span> <span class="title">build</span><span class="params">(<span class="type">int</span> l, <span class="type">int</span> r, <span class="type">int</span> root)</span></span>&#123;</span><br><span class="line">    <span class="keyword">if</span>(l &gt; r) <span class="keyword">return</span> ;</span><br><span class="line">    <span class="type">int</span> mid = (l + r) &gt;&gt; <span class="number">1</span>;</span><br><span class="line">    <span class="keyword">if</span>(mid &lt; root) snode[root].son[<span class="number">0</span>] = mid;</span><br><span class="line">    <span class="keyword">else</span> snode[root].son[<span class="number">1</span>] = mid;</span><br><span class="line">    snode[mid].fa = root;</span><br><span class="line">    snode[mid].size = <span class="number">1</span>;</span><br><span class="line">    <span class="keyword">if</span>(l == r) <span class="keyword">return</span> ;</span><br><span class="line">    <span class="built_in">build</span>(l, mid<span class="number">-1</span>, mid);</span><br><span class="line">    <span class="built_in">build</span>(mid+<span class="number">1</span>, r, mid);</span><br><span class="line">    <span class="built_in">pushup</span>(mid);</span><br><span class="line">&#125;</span><br><span class="line"><span class="function"><span class="type">int</span> <span class="title">main</span><span class="params">()</span></span>&#123;</span><br><span class="line">    <span class="built_in">scanf</span>(<span class="string">&quot;%d%d&quot;</span>,&amp;n,&amp;m);</span><br><span class="line">    rt = (n + <span class="number">3</span>) &gt;&gt; <span class="number">1</span>;</span><br><span class="line">    <span class="built_in">build</span>(<span class="number">1</span>, n+<span class="number">2</span>, rt);</span><br><span class="line">    <span class="keyword">while</span>(m--)&#123;</span><br><span class="line">        <span class="built_in">scanf</span>(<span class="string">&quot;%d%d&quot;</span>,&amp;qx,&amp;qy);</span><br><span class="line">        <span class="built_in">rev</span>(qx, qy+<span class="number">2</span>);</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">for</span>(<span class="type">int</span> i=<span class="number">2</span>; i&lt;=n+<span class="number">1</span>; i++) <span class="built_in">printf</span>(<span class="string">&quot;%d &quot;</span>,<span class="built_in">find</span>(rt, i) - <span class="number">1</span>);</span><br><span class="line">    <span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p><a target="_blank" rel="noopener" href="http://luogu.com.cn">luogu.com.cn</a> P3369 普通平衡树</p>
<p>​</p>
<figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;cstdio&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;iostream&gt;</span></span></span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">inline</span> <span class="type">int</span> <span class="title">read</span><span class="params">()</span></span>&#123;</span><br><span class="line">    <span class="type">int</span> v = <span class="number">0</span>, f = <span class="number">1</span>; <span class="type">char</span> ch = <span class="built_in">getchar</span>();</span><br><span class="line">    <span class="keyword">while</span>(!<span class="built_in">isdigit</span>(ch))&#123; <span class="keyword">if</span>(ch == <span class="string">&#x27;-&#x27;</span>) f = <span class="number">-1</span>; ch = <span class="built_in">getchar</span>(); &#125;</span><br><span class="line">    <span class="keyword">while</span>(<span class="built_in">isdigit</span>(ch))&#123; v = (v &lt;&lt; <span class="number">1</span>) + (v &lt;&lt; <span class="number">3</span>) + ch - <span class="number">48</span>; ch = <span class="built_in">getchar</span>(); &#125;</span><br><span class="line">    <span class="keyword">return</span> v * f;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="type">const</span> <span class="type">int</span> N = <span class="number">1e5</span>+<span class="number">4</span>, HINF = <span class="number">0x3fffffff</span>;</span><br><span class="line"><span class="type">int</span> fa[N], cnt[N], son[N][<span class="number">2</span>], val[N], size[N];</span><br><span class="line"><span class="type">int</span> root, idx, op, va, n;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">inline</span> <span class="type">void</span> <span class="title">update</span><span class="params">(<span class="type">int</span> x)</span></span>&#123;</span><br><span class="line">    size[x] = size[son[x][<span class="number">0</span>]] + size[son[x][<span class="number">1</span>]] + cnt[x];</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="type">void</span> <span class="title">rotate</span><span class="params">(<span class="type">int</span> x)</span></span>&#123;</span><br><span class="line">    <span class="type">int</span> y = fa[x], z = fa[y];</span><br><span class="line">    <span class="type">int</span> y2x = son[y][<span class="number">1</span>] == x, z2y = son[z][<span class="number">1</span>] == y;</span><br><span class="line">    son[z][z2y] = x, fa[x] = z;</span><br><span class="line">    son[y][y2x] = son[x][y2x ^ <span class="number">1</span>], fa[son[x][y2x ^ <span class="number">1</span>]] = y;</span><br><span class="line">    son[x][y2x ^ <span class="number">1</span>] = y , fa[y] = x;</span><br><span class="line">    <span class="built_in">update</span>(y), <span class="built_in">update</span>(x);</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="type">void</span> <span class="title">splay</span><span class="params">(<span class="type">int</span> x, <span class="type">int</span> goal)</span></span>&#123;</span><br><span class="line">    <span class="keyword">while</span>(fa[x] != goal)&#123;</span><br><span class="line">        <span class="type">int</span> y = fa[x], z = fa[y];</span><br><span class="line">        <span class="keyword">if</span>(z != goal)&#123;</span><br><span class="line">            <span class="keyword">if</span>((son[z][<span class="number">1</span>] == y) ^ (son[y][<span class="number">1</span>] == x)) <span class="built_in">rotate</span>(x);</span><br><span class="line">            <span class="keyword">else</span> <span class="built_in">rotate</span>(y);</span><br><span class="line">        &#125; </span><br><span class="line">        <span class="built_in">rotate</span>(x);</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">if</span>(!goal) root = x;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="type">void</span> <span class="title">find</span><span class="params">(<span class="type">int</span> x)</span></span>&#123;</span><br><span class="line">    <span class="keyword">if</span>(<span class="type">int</span> u = root)&#123;</span><br><span class="line">        <span class="keyword">while</span>(son[u][x &gt; val[u]] &amp;&amp; x != val[u])&#123;</span><br><span class="line">            u = son[u][x &gt; val[u]];</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="built_in">splay</span>(u, <span class="number">0</span>);</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="type">void</span> <span class="title">insert</span><span class="params">(<span class="type">int</span> x)</span></span>&#123;</span><br><span class="line">    <span class="type">int</span> u = root, ffa = <span class="number">0</span>;</span><br><span class="line">    <span class="keyword">while</span>(u &amp;&amp; val[u] != x)&#123;</span><br><span class="line">        ffa = u;</span><br><span class="line">        u = son[u][x &gt; val[u]];</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">if</span>(u) cnt[u] += <span class="number">1</span>;</span><br><span class="line">    <span class="keyword">else</span>&#123;</span><br><span class="line">        u = ++idx;</span><br><span class="line">        <span class="keyword">if</span>(ffa) son[ffa][x &gt; val[ffa]] = u;</span><br><span class="line">        son[u][<span class="number">0</span>] = son[u][<span class="number">1</span>] = <span class="number">0</span>;</span><br><span class="line">        fa[u] = ffa;</span><br><span class="line">        val[u] = x;</span><br><span class="line">        cnt[u] = size[u] = <span class="number">1</span>;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="built_in">splay</span>(u, <span class="number">0</span>);</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="type">int</span> <span class="title">pre_next</span><span class="params">(<span class="type">int</span> x, <span class="type">bool</span> isnext)</span></span>&#123;</span><br><span class="line">    <span class="built_in">find</span>(x);</span><br><span class="line">    <span class="type">int</span> u = root;</span><br><span class="line">    <span class="keyword">if</span>(val[u] &lt; x &amp;&amp; !isnext) <span class="keyword">return</span> u;</span><br><span class="line">    <span class="keyword">if</span>(val[u] &gt; x &amp;&amp; isnext) <span class="keyword">return</span> u;</span><br><span class="line">    u = son[u][isnext];</span><br><span class="line">    <span class="keyword">while</span>(son[u][isnext ^ <span class="number">1</span>]) u = son[u][isnext ^ <span class="number">1</span>];</span><br><span class="line">    <span class="keyword">return</span> u;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="type">void</span> _delete(<span class="type">int</span> x)&#123;</span><br><span class="line">    <span class="type">int</span> pre = <span class="built_in">pre_next</span>(x, <span class="number">0</span>), next = <span class="built_in">pre_next</span>(x, <span class="number">1</span>);</span><br><span class="line">    <span class="built_in">splay</span>(pre, <span class="number">0</span>), <span class="built_in">splay</span>(next, pre);</span><br><span class="line">    <span class="type">int</span> todel = son[next][<span class="number">0</span>];</span><br><span class="line">    <span class="keyword">if</span>(cnt[todel] &gt; <span class="number">1</span>)&#123;</span><br><span class="line">        cnt[todel] -= <span class="number">1</span>;</span><br><span class="line">        <span class="built_in">splay</span>(todel, <span class="number">0</span>);</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">else</span> son[next][<span class="number">0</span>] = <span class="number">0</span>;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="type">int</span> <span class="title">Kth</span><span class="params">(<span class="type">int</span> x)</span></span>&#123;</span><br><span class="line">    <span class="type">int</span> u = root;</span><br><span class="line">    <span class="keyword">if</span>(size[u] &lt; x) <span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">    <span class="keyword">while</span>(<span class="literal">true</span>)&#123;</span><br><span class="line">        <span class="keyword">if</span>(size[son[u][<span class="number">0</span>]] + cnt[u] &lt; x)&#123;</span><br><span class="line">            x -= size[son[u][<span class="number">0</span>]] + cnt[u];</span><br><span class="line">            u = son[u][<span class="number">1</span>];</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">else</span>&#123;</span><br><span class="line">            <span class="keyword">if</span>(size[son[u][<span class="number">0</span>]] &gt;= x) u = son[u][<span class="number">0</span>];</span><br><span class="line">            <span class="keyword">else</span> <span class="keyword">return</span> val[u];</span><br><span class="line">        &#125;</span><br><span class="line">    &#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="type">int</span> <span class="title">main</span><span class="params">()</span></span>&#123;</span><br><span class="line">    <span class="built_in">scanf</span>(<span class="string">&quot;%d&quot;</span>, &amp;n);</span><br><span class="line">    <span class="built_in">insert</span>(HINF); <span class="built_in">insert</span>(-HINF);</span><br><span class="line">    <span class="keyword">while</span>(n--)&#123;</span><br><span class="line">        <span class="built_in">scanf</span>(<span class="string">&quot;%d%d&quot;</span>, &amp;op, &amp;va);</span><br><span class="line">        <span class="keyword">if</span>(op == <span class="number">1</span>) <span class="built_in">insert</span>(va);</span><br><span class="line">        <span class="keyword">else</span> <span class="keyword">if</span>(op == <span class="number">2</span>) _delete(va);</span><br><span class="line">        <span class="keyword">else</span> <span class="keyword">if</span>(op == <span class="number">3</span>) &#123;</span><br><span class="line">            <span class="built_in">find</span>(va);</span><br><span class="line">            <span class="built_in">printf</span>(<span class="string">&quot;%d\n&quot;</span>, size[son[root][<span class="number">0</span>]]);</span><br><span class="line">        &#125;</span><br><span class="line">        <span class="keyword">else</span> <span class="keyword">if</span>(op == <span class="number">4</span>) <span class="built_in">printf</span>(<span class="string">&quot;%d\n&quot;</span>, <span class="built_in">Kth</span>(va + <span class="number">1</span>));</span><br><span class="line">        <span class="keyword">else</span> <span class="keyword">if</span>(op == <span class="number">5</span>) <span class="built_in">printf</span>(<span class="string">&quot;%d\n&quot;</span>, val[<span class="built_in">pre_next</span>(va, <span class="number">0</span>)]);</span><br><span class="line">        <span class="keyword">else</span> <span class="keyword">if</span>(op == <span class="number">6</span>) <span class="built_in">printf</span>(<span class="string">&quot;%d\n&quot;</span>, val[<span class="built_in">pre_next</span>(va, <span class="number">1</span>)]);</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://example.com/1111/11/11/Splay/" data-id="cl2uhoebe0009e4j35a0t9f19" class="article-share-link">分享</a>
      
      
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/OldBlog-Before20220505/" rel="tag">OldBlog(Before20220505)</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/Splay%E6%A0%91/" rel="tag">Splay树</a></li></ul>

    </footer>
  </div>
  
</article>




  
    <article id="post-YTU 3413_ 小姬小姬小姬" class="wow slideInRight article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/1111/11/11/YTU%203413_%20%E5%B0%8F%E5%A7%AC%E5%B0%8F%E5%A7%AC%E5%B0%8F%E5%A7%AC/" class="article-date">
  <time class="post-time" datetime="1111-11-11T03:06:11.000Z" itemprop="datePublished">
    <span class="post-month">11月</span><br/>
    <span class="post-day">11</span>
  </time>
</a>
   
  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/1111/11/11/YTU%203413_%20%E5%B0%8F%E5%A7%AC%E5%B0%8F%E5%A7%AC%E5%B0%8F%E5%A7%AC/">YTU 3413_ 小姬小姬小姬.md</a>
    </h1>
  

        <div>
          
  <div class="article-category">
    <a class="article-category-link" href="/categories/%E7%AE%97%E6%B3%95/">算法</a>,<a class="article-category-link" href="/categories/%E7%AE%97%E6%B3%95/%E7%9E%8E%E6%90%9E/">瞎搞</a>
  </div>

          
              

          
        </div>
      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <h2 id="说明-2022-05-05"><a class="markdownIt-Anchor" href="#说明-2022-05-05"></a> 说明 - 2022-05-05</h2>
<p>本篇博客为本人原创, 原发布于CSDN, 在搭建个人博客后使用爬虫批量爬取并挂到个人博客, 出于一些技术原因博客未能完全还原到初始版本(而且我懒得修改), 在观看体验上会有一些瑕疵 ,若有需求会发布重制版总结性新博客。发布时间统一定为1111年11月11日。钦此。</p>
<h2 id="题目描述"><a class="markdownIt-Anchor" href="#题目描述"></a> 题目描述</h2>
<p>小姬最近开始研究起了曼哈顿距离，因为他厌倦了欧氏距离的学习。</p>
<p>我们知道，平面内 (x1,y1) 与 (x2,y2) 的曼哈顿距离被定义为这两点在标准坐标系上的绝对轴距之和，即 |x1−x2|+|y1−y2|。</p>
<p>对于小姬来讲，他可以很容易的算出给定平面内任意多个点之间的曼哈顿距离，但是千千给小姬出了一个问题：假如我有 n(n−1)2 个数，它们分别代表平面中 n<br />
个点之间的曼哈顿距离，你能告诉我这 n 个点的位置么？</p>
<p>随后的几天，小姬开始困惑了，因为他想来想去也只会算当 n=2 的情形，于是便去找千千诉苦，看到这样的情形，千千只好答应降低难度，只要你算出 n=3<br />
的情形便可以啦。</p>
<p>你能帮小姬解决这个问题么？</p>
<h2 id="输入"><a class="markdownIt-Anchor" href="#输入"></a> 输入</h2>
<p>输入只有一行，包含三个正整数 a,b,c (1≤a,b,c≤100)，分别代表平面中 3 个点两两之间的曼哈顿距离。（保证输入数据有解）</p>
<h2 id="输出"><a class="markdownIt-Anchor" href="#输出"></a> 输出</h2>
<p>输出满足题意的三个点的坐标（要求<br />
0≤|x|,|y|≤105），每个点的坐标占一行，可以以任意的顺序输出，若存在多解的情况，输出任意一组即可。（如果你的答案计算出的结果与真实值相差 10−6<br />
以内则被认为是正确的）</p>
<h2 id="样例输入"><a class="markdownIt-Anchor" href="#样例输入"></a> 样例输入</h2>
<p>1 1 2</p>
<h2 id="样例输出"><a class="markdownIt-Anchor" href="#样例输出"></a> 样例输出</h2>
<p>0.000000 0.000000<br />
1.000000 0.000000<br />
0.000000 1.000000</p>
<h2 id="思路"><a class="markdownIt-Anchor" href="#思路"></a> 思路</h2>
<p>在这三个曼哈顿距离中任取一个d，它一定表示两点之间的曼哈顿距离<br />
设其中一个点为原点，则另一个点一定在以原点为中心距离远点曼哈顿距离为d的菱形（正方形）上。<br />
其他两个输入值，其中有一个值是于原点相关的曼哈顿距离，而这个值对应的点也应该是围绕原点的一个菱形（正方形）<br />
。<br />
不妨先假设其中一个值是与原点相关的曼哈顿距离，只要第三个值（原点除外的其他两点的曼哈顿距离）在区间【两菱形之间点的最短距离，两菱形点的最长距离】范围之内，则必定可以求解，如果不满足，则最后剩下的值才是与原点关联的值<br />
。<br />
这样我们就可以先直接定死两个点，求第三个点。<br />
先说两个菱形大小不一样的情况：<br />
如下图，（这个图我只看了右边）<br />
1.我定的点是（0，0）和小菱形最上端的点（0，x）<br />
图中上方表示红线（0，x）和求解点有最短距离时求解点存在的范围，在这一线段上（0，x）和求解点的曼哈顿距离相等，这个最短距离为abs（与原点相关的连个曼哈顿距离只差），若不关联原点的曼哈顿距离就是最短距离，则随便取红线上的一点就是答案<br />
2.同理，下方红线表示（0，x）和所求点曼哈顿距离最长的范围，若不关联原点的曼哈顿距离等于最长距离，则随便在下方红线上取一点就是答案<br />
3.在蓝线上（0，x）到求解点的曼哈顿距离递增<br />
我们可以先把求解点定在上方红线的最下边，这时求解点与（0，x）的曼哈顿距离为最短距离，然后再将求解点向下偏移，令两点之间的曼哈顿距离增长（不关联原点的曼哈顿距离-<br />
最短距离），得到的点就是答案（斜率都是1或-1呀）<br />
![在这里插入图片描述](<a target="_blank" rel="noopener" href="https://img-blog.csdnimg.cn/20201028223150512.png?x-oss-">https://img-blog.csdnimg.cn/20201028223150512.png?x-oss-</a><br />
process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dsZGNtenk=,size_16,color_FFFFFF,t_70#pic_center)<br />
如果两个菱形大小一样，最上方的红线就会变成一个点，其余思路不变，所以这种情况不用另外考虑 <s>战吼：放一个P</s></p>
<h2 id="代码"><a class="markdownIt-Anchor" href="#代码"></a> 代码</h2>
<p>一遍过的，里面有些冗余的东西写出来了根本没用上，比如那个结构体的点</p>
<p>​</p>
<figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;iostream&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;cstdio&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;cstring&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;string&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="keyword">include</span> <span class="string">&lt;cmath&gt;</span></span></span><br><span class="line"></span><br><span class="line"><span class="keyword">struct</span> <span class="title class_">Edge</span></span><br><span class="line">&#123;</span><br><span class="line">    <span class="type">float</span> x,y;</span><br><span class="line">&#125;p1,p2,p3;</span><br><span class="line"><span class="type">int</span> a,b,c;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="type">void</span> <span class="title">fun</span><span class="params">(<span class="type">float</span> p,<span class="type">float</span> q,<span class="type">float</span> w)</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    <span class="type">float</span> x,y,px,py,left;</span><br><span class="line">    <span class="keyword">if</span>(p&lt;q) x=p,y=q;</span><br><span class="line">    <span class="keyword">else</span> x=q,y=p;</span><br><span class="line">    <span class="keyword">if</span> (w == std::<span class="built_in">abs</span>(p-q))</span><br><span class="line">    &#123;</span><br><span class="line">        px=<span class="number">0</span>;</span><br><span class="line">        py=y;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">else</span> <span class="keyword">if</span>(w == p+q)</span><br><span class="line">    &#123;</span><br><span class="line">        px=<span class="number">0</span>;</span><br><span class="line">        py=-y;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">else</span></span><br><span class="line">    &#123;</span><br><span class="line">        <span class="type">float</span> tmp=std::<span class="built_in">abs</span>(p-q);</span><br><span class="line">        px=tmp,py=x;</span><br><span class="line">        left=w-tmp;</span><br><span class="line">        left/=<span class="number">2</span>;</span><br><span class="line">        px+=left;</span><br><span class="line">        py-=left;</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="built_in">printf</span>(<span class="string">&quot;%.6f %.6f\n&quot;</span>,<span class="number">0.0</span>,<span class="number">0.0</span>);</span><br><span class="line">    <span class="built_in">printf</span>(<span class="string">&quot;%.6f %.6f\n&quot;</span>,<span class="number">0.0</span>,x);</span><br><span class="line">    <span class="built_in">printf</span>(<span class="string">&quot;%.6f %.6f\n&quot;</span>,px,py);</span><br></pre></td></tr></table></figure>
<p>​</p>
<figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br></pre></td><td class="code"><pre><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="type">int</span> <span class="title">main</span><span class="params">()</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">    std::cin &gt;&gt; a &gt;&gt; b &gt;&gt; c;</span><br><span class="line">    p1.x=p1.y=<span class="number">0</span>;</span><br><span class="line">    <span class="keyword">if</span>(c&gt;= std::<span class="built_in">abs</span>(a-b) &amp;&amp; c&lt;= a+b)</span><br><span class="line">    &#123;</span><br><span class="line">        <span class="built_in">fun</span>(a,b,c);</span><br><span class="line">    &#125;</span><br><span class="line">    <span class="keyword">else</span></span><br><span class="line">    &#123;</span><br><span class="line">        <span class="built_in">fun</span>(a,c,b);</span><br><span class="line">    &#125;</span><br><span class="line"></span><br><span class="line">    <span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">&#125;</span><br></pre></td></tr></table></figure>
<p>​</p>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://example.com/1111/11/11/YTU%203413_%20%E5%B0%8F%E5%A7%AC%E5%B0%8F%E5%A7%AC%E5%B0%8F%E5%A7%AC/" data-id="cl2uhoebg000be4j35wly2t3g" class="article-share-link">分享</a>
      
      
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/OldBlog-Before20220505/" rel="tag">OldBlog(Before20220505)</a></li></ul>

    </footer>
  </div>
  
</article>




  
    <article id="post-git github 初用" class="wow slideInRight article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/1111/11/11/git%20github%20%E5%88%9D%E7%94%A8/" class="article-date">
  <time class="post-time" datetime="1111-11-11T03:06:11.000Z" itemprop="datePublished">
    <span class="post-month">11月</span><br/>
    <span class="post-day">11</span>
  </time>
</a>
   
  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/1111/11/11/git%20github%20%E5%88%9D%E7%94%A8/">git github 初用.md</a>
    </h1>
  

        <div>
          
  <div class="article-category">
    <a class="article-category-link" href="/categories/%E5%9F%BA%E7%A1%80%E7%9F%A5%E8%AF%86/">基础知识</a>,<a class="article-category-link" href="/categories/%E5%9F%BA%E7%A1%80%E7%9F%A5%E8%AF%86/git/">git</a>
  </div>

          
              

          
        </div>
      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <h2 id="说明-2022-05-05"><a class="markdownIt-Anchor" href="#说明-2022-05-05"></a> 说明 - 2022-05-05</h2>
<p>本篇博客为本人原创, 原发布于CSDN, 在搭建个人博客后使用爬虫批量爬取并挂到个人博客, 出于一些技术原因博客未能完全还原到初始版本(而且我懒得修改), 在观看体验上会有一些瑕疵 ,若有需求会发布重制版总结性新博客。发布时间统一定为1111年11月11日。钦此。</p>
<p>指定仓库的用户名和邮箱，–global表示这台机器的所有仓库都用这个用户名或邮箱</p>
<blockquote>
<p>wldcmzy@DESKTOP-UL0SE7R MINGW64 /D/test (master)<br />
$ git config --global <a target="_blank" rel="noopener" href="http://user.name">user.name</a> “wldcmzy”<br />
wldcmzy@DESKTOP-UL0SE7R MINGW64 /D/test (master)<br />
$ git config --global user.email “wldcmzy@163.com”</p>
</blockquote>
<p>将一个目录变为git可以管理的仓库</p>
<blockquote>
<p>cd 一个目录<br />
git init</p>
</blockquote>
<blockquote>
<p>git add：将文件提交到暂存区<br />
git commit -m：将暂存区文件提交到仓库（单引号内为注释）</p>
</blockquote>
<blockquote>
<p>git status：检查当前文件状态 git diff：查看文件修改的内容</p>
</blockquote>
<blockquote>
<p>git log：获得历史修改记录<br />
git log --pretty=oneline：使记录只显示主要的内容，一行显示</p>
</blockquote>
<blockquote>
<p>git reflog：获取历史版本号<br />
git reset --hard 版本号：回退到该版本号对应的版本<br />
git reset --hard HEAD^：回退到上1个版本<br />
git reset --hard HEAD^^：回退到上2个版本<br />
git reset --hard HEAD~50：回退到上50个版本</p>
</blockquote>
<p>好像是创造一个readme文件，否则以后push会出错</p>
<blockquote>
<p>git pull --rebase origin master</p>
</blockquote>
<blockquote>
<p>git remote add origin <a target="_blank" rel="noopener" href="https://github.com/Wldcmzy/test.git">https://github.com/Wldcmzy/test.git</a> 关联仓库</p>
</blockquote>
<blockquote>
<p>git push origin master 推送到仓库</p>
</blockquote>
<p>git checkout -b xxx</p>
<p>git checkout xxx</p>
<p>参考资料<br />
<a target="_blank" rel="noopener" href="https://www.cnblogs.com/imyalost/p/8777684.html">https://www.cnblogs.com/imyalost/p/8777684.html</a><br />
<a target="_blank" rel="noopener" href="https://www.cnblogs.com/imyalost/p/8762522.html">https://www.cnblogs.com/imyalost/p/8762522.html</a></p>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://example.com/1111/11/11/git%20github%20%E5%88%9D%E7%94%A8/" data-id="cl2uhoebi000ee4j30uwqcp6p" class="article-share-link">分享</a>
      
      
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/OldBlog-Before20220505/" rel="tag">OldBlog(Before20220505)</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/git/" rel="tag">git</a></li></ul>

    </footer>
  </div>
  
</article>




  
    <article id="post-python graphviz的使用  改日填坑" class="wow slideInRight article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/1111/11/11/python%20graphviz%E7%9A%84%E4%BD%BF%E7%94%A8%20%20%E6%94%B9%E6%97%A5%E5%A1%AB%E5%9D%91/" class="article-date">
  <time class="post-time" datetime="1111-11-11T03:06:11.000Z" itemprop="datePublished">
    <span class="post-month">11月</span><br/>
    <span class="post-day">11</span>
  </time>
</a>
   
  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/1111/11/11/python%20graphviz%E7%9A%84%E4%BD%BF%E7%94%A8%20%20%E6%94%B9%E6%97%A5%E5%A1%AB%E5%9D%91/">python graphviz的使用  改日填坑.md</a>
    </h1>
  

        <div>
          
  <div class="article-category">
    <a class="article-category-link" href="/categories/%E5%9F%BA%E7%A1%80%E7%9F%A5%E8%AF%86/">基础知识</a>,<a class="article-category-link" href="/categories/%E5%9F%BA%E7%A1%80%E7%9F%A5%E8%AF%86/python/">python</a>,<a class="article-category-link" href="/categories/%E5%9F%BA%E7%A1%80%E7%9F%A5%E8%AF%86/python/graphviz/">graphviz</a>
  </div>

          
              

          
        </div>
      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <h2 id="说明-2022-05-05"><a class="markdownIt-Anchor" href="#说明-2022-05-05"></a> 说明 - 2022-05-05</h2>
<p>本篇博客为本人原创, 原发布于CSDN, 在搭建个人博客后使用爬虫批量爬取并挂到个人博客, 出于一些技术原因博客未能完全还原到初始版本(而且我懒得修改), 在观看体验上会有一些瑕疵 ,若有需求会发布重制版总结性新博客。发布时间统一定为1111年11月11日。钦此。</p>
<p>抄了半个大致模板 自己研究了研究了研究，现在先会画流程图 改日详细填坑</p>
<p>​</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">from</span> graphviz <span class="keyword">import</span> Digraph</span><br><span class="line"><span class="keyword">from</span> graphviz <span class="keyword">import</span> Source</span><br><span class="line">dot = Digraph(</span><br><span class="line">    name=<span class="string">&#x27;try1&#x27;</span>,</span><br><span class="line">    comment=<span class="string">&#x27;&#x27;</span>,</span><br><span class="line">    filename=<span class="literal">None</span>,</span><br><span class="line">    directory=<span class="literal">None</span>,</span><br><span class="line">    <span class="built_in">format</span>=<span class="string">&quot;png&quot;</span>,</span><br><span class="line">    engine=<span class="literal">None</span>,</span><br><span class="line">    encoding=<span class="string">&#x27;utf8&#x27;</span>,</span><br><span class="line">    graph_attr=&#123;<span class="string">&#x27;rankdir&#x27;</span>:<span class="string">&#x27;TB&#x27;</span>&#125;,</span><br><span class="line">    node_attr=&#123;<span class="string">&#x27;color&#x27;</span>:<span class="string">&#x27;black&#x27;</span>,<span class="string">&#x27;fontcolor&#x27;</span>:<span class="string">&#x27;black&#x27;</span>,<span class="string">&#x27;fontname&#x27;</span>:<span class="string">&#x27;FangSong&#x27;</span>,<span class="string">&#x27;fontsize&#x27;</span>:<span class="string">&#x27;12&#x27;</span>,<span class="string">&#x27;style&#x27;</span>:<span class="string">&#x27;rounded&#x27;</span>,<span class="string">&#x27;shape&#x27;</span>:<span class="string">&#x27;box&#x27;</span>&#125;,</span><br><span class="line">    edge_attr=&#123;<span class="string">&#x27;color&#x27;</span>:<span class="string">&#x27;red&#x27;</span>,<span class="string">&#x27;fontcolor&#x27;</span>:<span class="string">&#x27;#888888&#x27;</span>,<span class="string">&#x27;fontsize&#x27;</span>:<span class="string">&#x27;10&#x27;</span>,<span class="string">&#x27;fontname&#x27;</span>:<span class="string">&#x27;FangSong&#x27;</span>&#125;,</span><br><span class="line">    body=<span class="literal">None</span>,</span><br><span class="line">    strict=<span class="literal">False</span></span><br><span class="line">)</span><br><span class="line">dot.node(<span class="string">&#x27;A&#x27;</span>,<span class="string">&#x27;A-----&#x27;</span>,shape = <span class="string">&#x27;rectangle&#x27;</span>)</span><br><span class="line">dot.node(<span class="string">&#x27;B&#x27;</span>,<span class="string">&#x27;B=====&#x27;</span>,shape = <span class="string">&#x27;circle&#x27;</span>)</span><br><span class="line">dot.node(<span class="string">&#x27;C&#x27;</span>, <span class="string">&#x27;C-----&#x27;</span>,shape = <span class="string">&#x27;triangle&#x27;</span>, color = <span class="string">&#x27;blue&#x27;</span>, fontcolor = <span class="string">&#x27;green&#x27;</span>)</span><br><span class="line">dot.node(<span class="string">&#x27;D&#x27;</span>,<span class="string">&#x27;D=====&#x27;</span>,shape = <span class="string">&#x27;circle&#x27;</span>)</span><br><span class="line">dot.view()</span><br><span class="line"><span class="string">&#x27;try1.gv.png&#x27;</span></span><br><span class="line">dot.edge(<span class="string">&#x27;A&#x27;</span>,<span class="string">&#x27;B&#x27;</span>,<span class="string">&#x27;E GAY WOLY GIAO&#x27;</span>)</span><br><span class="line">dot.edge(<span class="string">&#x27;A&#x27;</span>,<span class="string">&#x27;D&#x27;</span>,<span class="string">&#x27;ss&#x27;</span>)</span><br><span class="line">dot.edge(<span class="string">&#x27;D&#x27;</span>,<span class="string">&#x27;C&#x27;</span>)</span><br><span class="line">dot.edge(<span class="string">&#x27;C&#x27;</span>,<span class="string">&#x27;A&#x27;</span>)</span><br><span class="line">dot.edge(<span class="string">&#x27;C&#x27;</span>,<span class="string">&#x27;D&#x27;</span>)</span><br><span class="line">dot.view()</span><br><span class="line"><span class="string">&#x27;try1.gv.png&#x27;</span></span><br></pre></td></tr></table></figure>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://example.com/1111/11/11/python%20graphviz%E7%9A%84%E4%BD%BF%E7%94%A8%20%20%E6%94%B9%E6%97%A5%E5%A1%AB%E5%9D%91/" data-id="cl2uhoebn000ke4j37sts5vrm" class="article-share-link">分享</a>
      
      
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/OldBlog-Before20220505/" rel="tag">OldBlog(Before20220505)</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/%E7%94%BB%E5%9B%BE/" rel="tag">画图</a></li></ul>

    </footer>
  </div>
  
</article>




  
    <article id="post-sql学习记录（sql sever）" class="wow slideInRight article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/1111/11/11/sql%E5%AD%A6%E4%B9%A0%E8%AE%B0%E5%BD%95%EF%BC%88sql%20sever%EF%BC%89/" class="article-date">
  <time class="post-time" datetime="1111-11-11T03:06:11.000Z" itemprop="datePublished">
    <span class="post-month">11月</span><br/>
    <span class="post-day">11</span>
  </time>
</a>
   
  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/1111/11/11/sql%E5%AD%A6%E4%B9%A0%E8%AE%B0%E5%BD%95%EF%BC%88sql%20sever%EF%BC%89/">sql学习记录（sql sever）.md</a>
    </h1>
  

        <div>
          
  <div class="article-category">
    <a class="article-category-link" href="/categories/%E5%9F%BA%E7%A1%80%E7%9F%A5%E8%AF%86/">基础知识</a>,<a class="article-category-link" href="/categories/%E5%9F%BA%E7%A1%80%E7%9F%A5%E8%AF%86/sql/">sql</a>
  </div>

          
              

          
        </div>
      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <h2 id="说明-2022-05-05"><a class="markdownIt-Anchor" href="#说明-2022-05-05"></a> 说明 - 2022-05-05</h2>
<p>本篇博客为本人原创, 原发布于CSDN, 在搭建个人博客后使用爬虫批量爬取并挂到个人博客, 出于一些技术原因博客未能完全还原到初始版本(而且我懒得修改), 在观看体验上会有一些瑕疵 ,若有需求会发布重制版总结性新博客。发布时间统一定为1111年11月11日。钦此。</p>
<p><s>其实是补之前没交的sql作业</s></p>
<h2 id="1非常基本的操作"><a class="markdownIt-Anchor" href="#1非常基本的操作"></a> 1.非常基本的操作</h2>
<h5 id="新建数据库"><a class="markdownIt-Anchor" href="#新建数据库"></a> 新建数据库</h5>
<p>​</p>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">create</span> database L4C2</span><br></pre></td></tr></table></figure>
<h5 id="新建表"><a class="markdownIt-Anchor" href="#新建表"></a> 新建表</h5>
<p>PID为主键</p>
<p>​</p>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">create</span> <span class="keyword">table</span> L4C2.dbo.Person</span><br><span class="line">(</span><br><span class="line">	PID <span class="type">nchar</span>(<span class="number">15</span>),</span><br><span class="line">	PName <span class="type">nchar</span>(<span class="number">25</span>),</span><br><span class="line">	PRole <span class="type">nchar</span>(<span class="number">10</span>),</span><br><span class="line">	Lucky <span class="type">int</span>,</span><br><span class="line">	Ammo <span class="type">int</span></span><br><span class="line">	<span class="keyword">primary</span> key(PID)</span><br><span class="line">)</span><br></pre></td></tr></table></figure>
<h5 id="增加列"><a class="markdownIt-Anchor" href="#增加列"></a> 增加列</h5>
<p>​</p>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">alter</span> <span class="keyword">table</span> L4C2.dbo.Person <span class="keyword">add</span> Ping <span class="type">int</span></span><br></pre></td></tr></table></figure>
<h5 id="修改列"><a class="markdownIt-Anchor" href="#修改列"></a> 修改列</h5>
<p>修改列的数据类型</p>
<p>​</p>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">alter</span> <span class="keyword">table</span> L4C2.dbo.Person <span class="keyword">alter</span> <span class="keyword">column</span> Lucky <span class="type">varchar</span>(<span class="number">10</span>)</span><br></pre></td></tr></table></figure>
<h5 id="删除列"><a class="markdownIt-Anchor" href="#删除列"></a> 删除列</h5>
<p>​</p>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">alter</span> <span class="keyword">table</span> L4C2.dbo.Person <span class="keyword">drop</span> <span class="keyword">column</span> Lucky</span><br></pre></td></tr></table></figure>
<h5 id="给表增加行"><a class="markdownIt-Anchor" href="#给表增加行"></a> 给表增加行</h5>
<p>增加多行，给所有列赋值</p>
<p>​</p>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">insert</span> <span class="keyword">into</span> L4C2.dbo.Person <span class="keyword">values</span></span><br><span class="line">(<span class="number">1234567</span>,<span class="string">&#x27;EVO.T im a&#x27;</span>,<span class="string">&#x27;Ellis&#x27;</span>,<span class="number">700</span>,<span class="number">230</span>),</span><br><span class="line">(<span class="number">1234568</span>,<span class="string">&#x27;EVO.Star&#x27;</span>,<span class="string">&#x27;Smoker&#x27;</span>,<span class="number">0</span>,<span class="number">225</span>),</span><br><span class="line">(<span class="number">1234569</span>,<span class="string">&#x27;Double.Mayuyu&#x27;</span>,<span class="string">&#x27;Coach&#x27;</span>,<span class="number">80</span>,<span class="number">40</span>),</span><br><span class="line">(<span class="number">1234570</span>,<span class="string">&#x27;dec.nv&#x27;</span>,<span class="string">&#x27;Nick&#x27;</span>,<span class="number">0</span>,<span class="number">233</span>),</span><br><span class="line">(<span class="number">1234571</span>,<span class="string">&#x27;kain.nv&#x27;</span>,<span class="string">&#x27;Charger&#x27;</span>,<span class="number">0</span>,<span class="number">125</span>);</span><br></pre></td></tr></table></figure>
<p>给特定列赋值</p>
<p>​</p>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">insert</span> <span class="keyword">into</span> L4C2.dbo.Person (PID,PName,PRole) <span class="keyword">values</span> (<span class="number">7654321</span>,<span class="string">&#x27;NPC.Bilibili.Deadz&#x27;</span>,<span class="string">&#x27;spectator&#x27;</span>)</span><br></pre></td></tr></table></figure>
<h5 id="创建索引"><a class="markdownIt-Anchor" href="#创建索引"></a> 创建索引</h5>
<p>按照Ping创建降序索引</p>
<p>​</p>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">create</span> index idx_Ping <span class="keyword">on</span> L4C2.dbo.Person(Ping <span class="keyword">desc</span>)</span><br></pre></td></tr></table></figure>
<p>按照Ammo创建升序索引</p>
<p>​</p>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">create</span> index idx_Ammo <span class="keyword">on</span> L4C2.dbo.Person(Ping <span class="keyword">asc</span>)</span><br></pre></td></tr></table></figure>
<h5 id="删除索引"><a class="markdownIt-Anchor" href="#删除索引"></a> 删除索引</h5>
<p>​</p>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">drop</span> index idx_Ping <span class="keyword">on</span> L4C2.dbo.Person</span><br></pre></td></tr></table></figure>
<h2 id="2查询训练"><a class="markdownIt-Anchor" href="#2查询训练"></a> 2.查询训练</h2>
<p>1.查找年级为2001的学生，按学号降序排列</p>
<p>​</p>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">select</span> STname <span class="keyword">from</span> University.dbo.Student</span><br><span class="line"><span class="keyword">where</span> STgrade <span class="operator">=</span> <span class="number">2001</span></span><br><span class="line"><span class="keyword">order</span> <span class="keyword">by</span> STid <span class="keyword">desc</span></span><br></pre></td></tr></table></figure>
<p>查找年级为2001的学生，按学号升序排列</p>
<p>​</p>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">select</span> STname <span class="keyword">from</span> University.dbo.Student</span><br><span class="line"><span class="keyword">where</span> STgrade <span class="operator">=</span> <span class="number">2001</span></span><br><span class="line"><span class="keyword">order</span> <span class="keyword">by</span> STid <span class="keyword">asc</span></span><br></pre></td></tr></table></figure>
<p>查询所有选课课程中及格的分数，并将其换算为绩点（60分为1，每增加一分，绩点+0.1）</p>
<p>​</p>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">select</span> (SCore<span class="number">-60</span>)<span class="operator">/</span><span class="number">10</span><span class="operator">+</span><span class="number">1</span> <span class="keyword">from</span> University.dbo.SC</span><br><span class="line"><span class="keyword">where</span> SCore <span class="operator">&gt;=</span> <span class="number">60</span></span><br></pre></td></tr></table></figure>
<p>查询课时为48或24的课程的名称</p>
<p>​</p>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">select</span> CRname <span class="keyword">from</span> University.dbo.Course x</span><br><span class="line"><span class="keyword">where</span> x.CRtimes<span class="operator">=</span><span class="number">48</span> <span class="keyword">or</span> x.CRtimes<span class="operator">=</span><span class="number">24</span></span><br></pre></td></tr></table></figure>
<p>查询课程名中带有data的课程的编号</p>
<p>​</p>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">select</span> CRid <span class="keyword">from</span> University.dbo.Course x</span><br><span class="line"><span class="keyword">where</span> x.CRname <span class="keyword">like</span> <span class="string">&#x27;%data%&#x27;</span></span><br></pre></td></tr></table></figure>
<p>查询所有选课记录中的课程号，不重复显示</p>
<p>​</p>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">select</span> <span class="keyword">distinct</span> CRid <span class="keyword">from</span> University.dbo.SC x</span><br></pre></td></tr></table></figure>
<p>老师的平均工资</p>
<p>​</p>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">select</span> <span class="built_in">avg</span>(THsalary) <span class="keyword">from</span> University.dbo.Teacher</span><br></pre></td></tr></table></figure>
<p>查询所有学生编号和平均成绩，按照平均成绩降序排序</p>
<p>​</p>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">select</span> STid,<span class="built_in">avg</span>(SCore) <span class="keyword">from</span> University.dbo.SC</span><br><span class="line"><span class="keyword">group</span> <span class="keyword">by</span> STid</span><br><span class="line"><span class="keyword">order</span> <span class="keyword">by</span> <span class="built_in">avg</span>(SCore) <span class="keyword">desc</span></span><br></pre></td></tr></table></figure>
<p>统计所有课程的选课人数和平均成绩</p>
<p>​</p>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">select</span> CRid,<span class="built_in">count</span>(CRid) <span class="string">&#x27;人数&#x27;</span>,<span class="built_in">avg</span>(SCore) <span class="string">&#x27;平均成绩&#x27;</span></span><br><span class="line"><span class="keyword">from</span> University.dbo.SC</span><br><span class="line"><span class="keyword">group</span> <span class="keyword">by</span> CRid</span><br></pre></td></tr></table></figure>
<p>查询至少选修了三门课的学生号</p>
<p>​</p>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">select</span> STid <span class="keyword">from</span> University.dbo.SC</span><br><span class="line"><span class="keyword">group</span> <span class="keyword">by</span> STid</span><br><span class="line"><span class="keyword">having</span> <span class="built_in">count</span>(<span class="operator">*</span>) <span class="operator">&gt;=</span> <span class="number">3</span></span><br></pre></td></tr></table></figure>
<p>查询学号为2001001的学生选修的课程名和成绩</p>
<p>​</p>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">select</span> CRname,Score </span><br><span class="line"><span class="keyword">from</span> University.dbo.SC s, University.dbo.Course c</span><br><span class="line"><span class="keyword">where</span> s.CRid <span class="operator">=</span> c.CRid <span class="keyword">and</span> s.STid <span class="operator">=</span> <span class="string">&#x27;2001001&#x27;</span></span><br></pre></td></tr></table></figure>
<p>查询所有选了database课的学生id</p>
<p>​</p>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">select</span> STid</span><br><span class="line"><span class="keyword">from</span> University.dbo.Course c , University.dbo.SC sc</span><br><span class="line"><span class="keyword">where</span> c.CRname <span class="operator">=</span> <span class="string">&#x27;database&#x27;</span> <span class="keyword">and</span> sc.CRid <span class="operator">=</span> c.CRid</span><br></pre></td></tr></table></figure>
<p>查询所有选了同一课程的学生对</p>
<p>​</p>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">select</span> <span class="keyword">distinct</span> x.STid A,y.STid B</span><br><span class="line"><span class="keyword">from</span> University.dbo.SC x,University.dbo.SC y</span><br><span class="line"><span class="keyword">where</span> x.CRid <span class="operator">=</span> y.CRid <span class="keyword">and</span> x.STid<span class="operator">&lt;</span>y.STid</span><br></pre></td></tr></table></figure>
<p>查询至少有两人选修的课程id</p>
<p>​</p>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">select</span> CRid</span><br><span class="line"><span class="keyword">from</span> University.dbo.SC</span><br><span class="line"><span class="keyword">group</span> <span class="keyword">by</span> CRid</span><br><span class="line"><span class="keyword">having</span> <span class="built_in">count</span>(<span class="operator">*</span>) <span class="operator">&gt;=</span><span class="number">2</span></span><br></pre></td></tr></table></figure>
<p>查询跟学号2001001的学生共同上课的学生的编号</p>
<p>​</p>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">select</span> <span class="keyword">distinct</span> y.STid</span><br><span class="line"><span class="keyword">from</span> University.dbo.SC x, University.dbo.SC y</span><br><span class="line"><span class="keyword">where</span> x.CRid <span class="operator">=</span> y.CRid <span class="keyword">and</span> x.STid <span class="operator">=</span> <span class="string">&#x27;2001001&#x27;</span><span class="keyword">and</span> x.STid <span class="operator">&lt;&gt;</span> y.STid</span><br></pre></td></tr></table></figure>
<p>查询学号为2001001的学生的姓名，以及其所有选课的课程名与成绩</p>
<p>​</p>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">select</span> <span class="keyword">distinct</span> s.STname,c.CRname,sc.SCore</span><br><span class="line"><span class="keyword">from</span> University.dbo.SC sc , University.dbo.Course c , University.dbo.Student s</span><br><span class="line"><span class="keyword">where</span> s.STid <span class="operator">=</span> sc.STid <span class="keyword">and</span> sc.CRid <span class="operator">=</span> c.CRid <span class="keyword">and</span> s.STid <span class="operator">=</span> <span class="string">&#x27;2001001&#x27;</span></span><br></pre></td></tr></table></figure>
<p>查询所有选了课的学生的基本信息以及课程名和成绩</p>
<p>​</p>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">select</span> <span class="keyword">distinct</span> s.STid,s.STname,s.STgrade,c.CRname,sc.SCore</span><br><span class="line"><span class="keyword">from</span> University.dbo.SC sc , University.dbo.Course c , University.dbo.Student s</span><br><span class="line"><span class="keyword">where</span> s.STid <span class="operator">=</span> sc.STid <span class="keyword">and</span> sc.CRid <span class="operator">=</span> c.CRid</span><br></pre></td></tr></table></figure>
<p>查询与学号为2001001同年级的学生的信息</p>
<p>​</p>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">select</span> <span class="operator">*</span></span><br><span class="line"><span class="keyword">from</span> University.dbo.Student</span><br><span class="line"><span class="keyword">where</span> STgrade <span class="operator">=</span> (</span><br><span class="line">	<span class="keyword">select</span> STgrade</span><br><span class="line">	<span class="keyword">from</span> University.dbo.Student</span><br><span class="line">	<span class="keyword">where</span> STid <span class="operator">=</span> <span class="string">&#x27;2001001&#x27;</span></span><br><span class="line">)</span><br></pre></td></tr></table></figure>
<p>​</p>
<p>查询所有选了课的学生信息</p>
<p>​</p>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">select</span> <span class="operator">*</span></span><br><span class="line"><span class="keyword">from</span> University.dbo.Student</span><br><span class="line"><span class="keyword">where</span> STid <span class="keyword">in</span> (</span><br><span class="line">	<span class="keyword">select</span> STid</span><br><span class="line">	<span class="keyword">from</span> University.dbo.SC</span><br><span class="line">)</span><br></pre></td></tr></table></figure>
<p>​</p>
<p>查询没有人选的课程的编号</p>
<p>​</p>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">select</span> CRid</span><br><span class="line"><span class="keyword">from</span> University.dbo.Course</span><br><span class="line"><span class="keyword">where</span> CRid <span class="keyword">not</span> <span class="keyword">in</span> (</span><br><span class="line">	<span class="keyword">select</span> CRid</span><br><span class="line">	<span class="keyword">from</span> University.dbo.SC</span><br><span class="line">)</span><br></pre></td></tr></table></figure>
<p>查询所有选了课程名为cpp的课程的学生姓名</p>
<p>​</p>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">select</span> STname</span><br><span class="line"><span class="keyword">from</span> University.dbo.Student</span><br><span class="line"><span class="keyword">where</span> STid <span class="keyword">in</span> (</span><br><span class="line">	<span class="keyword">select</span> STid</span><br><span class="line">	<span class="keyword">from</span> University.dbo.SC</span><br><span class="line">	<span class="keyword">where</span> CRid <span class="keyword">in</span>(</span><br><span class="line">		<span class="keyword">select</span> CRid</span><br><span class="line">		<span class="keyword">from</span> University.dbo.Course</span><br><span class="line">		<span class="keyword">where</span> CRname <span class="operator">=</span> <span class="string">&#x27;cpp&#x27;</span></span><br><span class="line">	)</span><br><span class="line">)</span><br></pre></td></tr></table></figure>
<p>​</p>
<p>查询成绩最差的成绩状况</p>
<p>​</p>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">select</span> <span class="operator">*</span> <span class="keyword">from</span> University.dbo.SC x</span><br><span class="line"><span class="keyword">where</span> x.SCore <span class="operator">&lt;=</span> <span class="keyword">ALL</span>(</span><br><span class="line">	<span class="keyword">select</span> SCore <span class="keyword">from</span> SC <span class="keyword">where</span> SCore <span class="keyword">is</span> <span class="keyword">not</span> <span class="keyword">NULL</span></span><br><span class="line">)</span><br></pre></td></tr></table></figure>
<p>查询课时跟python或java一样长的课程名</p>
<p>​</p>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">select</span> CRname <span class="keyword">from</span> University.dbo.Course</span><br><span class="line"><span class="keyword">where</span> CRtimes <span class="operator">=</span> <span class="keyword">some</span>(</span><br><span class="line"><span class="keyword">select</span> CRtimes <span class="keyword">from</span> University.dbo.Course x</span><br><span class="line"><span class="keyword">where</span> CRname <span class="operator">=</span> <span class="string">&#x27;Java&#x27;</span> <span class="keyword">or</span> CRname <span class="operator">=</span> <span class="string">&#x27;Python&#x27;</span></span><br><span class="line">)</span><br></pre></td></tr></table></figure>
<p>查询选了1001号课的学生名字</p>
<p>​</p>
<figure class="highlight sql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">select</span> STname <span class="keyword">from</span> University.dbo.Student y</span><br><span class="line"><span class="keyword">where</span> <span class="keyword">exists</span>(</span><br><span class="line">	<span class="keyword">select</span> <span class="operator">*</span> <span class="keyword">from</span> University.dbo.SC x</span><br><span class="line">	<span class="keyword">where</span> x.CRid <span class="operator">=</span> <span class="string">&#x27;1001&#x27;</span> <span class="keyword">and</span> y.STid <span class="operator">=</span> x.STid</span><br><span class="line">)</span><br></pre></td></tr></table></figure>
<p>查询选修了所有课程的学生的姓名</p>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://example.com/1111/11/11/sql%E5%AD%A6%E4%B9%A0%E8%AE%B0%E5%BD%95%EF%BC%88sql%20sever%EF%BC%89/" data-id="cl2uhoebp000ne4j34nz42qne" class="article-share-link">分享</a>
      
      
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/OldBlog-Before20220505/" rel="tag">OldBlog(Before20220505)</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/sql/" rel="tag">sql</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/%E6%95%B0%E6%8D%AE%E5%BA%93/" rel="tag">数据库</a></li></ul>

    </footer>
  </div>
  
</article>




  
    <article id="post-python 简单的颜色序列生成器" class="wow slideInRight article article-type-post" itemscope itemprop="blogPost">
  <div class="article-meta">
    <a href="/1111/11/11/python%20%E7%AE%80%E5%8D%95%E7%9A%84%E9%A2%9C%E8%89%B2%E5%BA%8F%E5%88%97%E7%94%9F%E6%88%90%E5%99%A8/" class="article-date">
  <time class="post-time" datetime="1111-11-11T03:06:11.000Z" itemprop="datePublished">
    <span class="post-month">11月</span><br/>
    <span class="post-day">11</span>
  </time>
</a>
   
  </div>
  <div class="article-inner">
    
    
      <header class="article-header">
        
  
    <h1 itemprop="name">
      <a class="article-title" href="/1111/11/11/python%20%E7%AE%80%E5%8D%95%E7%9A%84%E9%A2%9C%E8%89%B2%E5%BA%8F%E5%88%97%E7%94%9F%E6%88%90%E5%99%A8/">python 简单的颜色序列生成器.md</a>
    </h1>
  

        <div>
          
  <div class="article-category">
    <a class="article-category-link" href="/categories/%E6%95%99%E7%BB%83%E6%88%91%E6%83%B3%E5%AD%A6%E6%8C%82%E8%BE%B9%E8%BA%B2%E7%89%9B/">教练我想学挂边躲牛</a>,<a class="article-category-link" href="/categories/%E6%95%99%E7%BB%83%E6%88%91%E6%83%B3%E5%AD%A6%E6%8C%82%E8%BE%B9%E8%BA%B2%E7%89%9B/%E6%9D%82%E4%B9%B1/">杂乱</a>
  </div>

          
              

          
        </div>
      </header>
    
    <div class="article-entry" itemprop="articleBody">
      
        <h2 id="说明-2022-05-05"><a class="markdownIt-Anchor" href="#说明-2022-05-05"></a> 说明 - 2022-05-05</h2>
<p>本篇博客为本人原创, 原发布于CSDN, 在搭建个人博客后使用爬虫批量爬取并挂到个人博客, 出于一些技术原因博客未能完全还原到初始版本(而且我懒得修改), 在观看体验上会有一些瑕疵 ,若有需求会发布重制版总结性新博客。发布时间统一定为1111年11月11日。钦此。</p>
<h2 id="20210421我火星了"><a class="markdownIt-Anchor" href="#20210421我火星了"></a> 2021/04/21：我火星了？？？？</h2>
<p>python Seaborn库 调色板</p>
<h2 id="所以下面的东西都别看了"><a class="markdownIt-Anchor" href="#所以下面的东西都别看了"></a> 所以下面的东西都别看了</h2>
<h2 id=""><a class="markdownIt-Anchor" href="#"></a> .</h2>
<h2 id="-2"><a class="markdownIt-Anchor" href="#-2"></a> .</h2>
<h2 id="-3"><a class="markdownIt-Anchor" href="#-3"></a> .</h2>
<h2 id="-4"><a class="markdownIt-Anchor" href="#-4"></a> .</h2>
<h2 id="-5"><a class="markdownIt-Anchor" href="#-5"></a> .</h2>
<h2 id="-6"><a class="markdownIt-Anchor" href="#-6"></a> .</h2>
<h2 id="-7"><a class="markdownIt-Anchor" href="#-7"></a> .</h2>
<h2 id="-8"><a class="markdownIt-Anchor" href="#-8"></a> .</h2>
<h2 id="-9"><a class="markdownIt-Anchor" href="#-9"></a> .</h2>
<h2 id="-10"><a class="markdownIt-Anchor" href="#-10"></a> .</h2>
<h2 id="由来"><a class="markdownIt-Anchor" href="#由来"></a> 由来</h2>
<p>昨天画了这张图，自动分配的颜色比较深，而且总颜色数不多，这张图的颜色是自己一点一点写的，很麻烦，所以想制作一个简单的颜色序列生成器一劳永逸<br />
![在这里插入图片描述](<a target="_blank" rel="noopener" href="https://img-blog.csdnimg.cn/20210209193159338.png?x-oss-">https://img-blog.csdnimg.cn/20210209193159338.png?x-oss-</a><br />
process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dsZGNtenk=,size_16,color_FFFFFF,t_70#pic_center)</p>
<h2 id="介绍"><a class="markdownIt-Anchor" href="#介绍"></a> 介绍</h2>
<p><a target="_blank" rel="noopener" href="http://xn--InterestingColorfulColor-p091b5l92oo66bukbl78u1owamg9plire.py">我给这个文件取名为InterestingColorfulColor.py</a>，把它放在python安装目录的Lib文件夹就可以随时用import语句导入，非常方便。<br />
例如：</p>
<p>​</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> InterestingColorfulColor <span class="keyword">as</span> ICC</span><br></pre></td></tr></table></figure>
<p>目前这个文件的主要内容只有一个类：ColorOrder<br />
ColorOrder类里给出了15种按照颜色深浅梯度变化的基础颜色序列，分别为：<br />
<strong>红，红橙，橙，橙黄，黄，黄绿，绿，绿青，青，青蓝，蓝，蓝紫，紫，紫红，和灰色</strong> （由纯黑到纯白）<br />
每种序列有16种不同的颜色。<br />
<strong>通过这个类可以较为轻松地得到一种你想要的颜色序列</strong> ，有可能可以让你的工作提高一点点效率。不过这毕竟是个小制作，功能不复杂。<br />
下图展示其中一部分颜色<br />
![在这里插入图片描述](<a target="_blank" rel="noopener" href="https://img-blog.csdnimg.cn/20210209193935836.png?x-oss-">https://img-blog.csdnimg.cn/20210209193935836.png?x-oss-</a><br />
process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dsZGNtenk=,size_16,color_FFFFFF,t_70#pic_center)</p>
<h2 id="使用"><a class="markdownIt-Anchor" href="#使用"></a> 使用</h2>
<h4 id="约定"><a class="markdownIt-Anchor" href="#约定"></a> 约定</h4>
<p>约定上述15种颜色序列为 gray <strong>red, orange,yellow,green,cyan,blue,purple</strong><br />
以及除了gray外剩下七种颜色中相邻颜色之间的两两组合 如redorange,<br />
greencyan等，对两种颜色书写的先后顺序不做要求即redpurple和purplered都是正确的</p>
<h4 id="导入模块"><a class="markdownIt-Anchor" href="#导入模块"></a> 导入模块</h4>
<p>​</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">import</span> InterestingColorfulColor <span class="keyword">as</span> ICC</span><br></pre></td></tr></table></figure>
<h4 id="创建一个colororder对象"><a class="markdownIt-Anchor" href="#创建一个colororder对象"></a> 创建一个ColorOrder对象</h4>
<p>​</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">co = ICC.ColorOrder([<span class="string">&#x27;red&#x27;</span>,<span class="string">&#x27;blue&#x27;</span>],mixtype = <span class="string">&#x27;cross&#x27;</span>)</span><br></pre></td></tr></table></figure>
<p>参数解析：<br />
def <strong>init</strong> (self, colornames, mixtype = ‘Connect’)<br />
<strong>两个参数，colornames ， mixtype</strong></p>
<p><strong>参数colornamse给出若干个颜色序列的名称。</strong><br />
<strong>参数mixtype表示混合这些颜色序列的方式，目前只有两个值：connect 和 cross</strong> （不需要区分大小写）<br />
connect为默认值 以连接的方式混合，即按照顺序依次把colornames中给出的颜色序列首尾相接<br />
cross 以交叉的方式混合 。举个例子 如果以cross的方式混合三个颜色序列[1,2,3][a,b,c][x,y,z]<br />
最后的结果序列为[1,a,x,2,b,y,3,c,z]</p>
<h4 id="查看颜色序列以及其他两个隐藏属性"><a class="markdownIt-Anchor" href="#查看颜色序列以及其他两个隐藏属性"></a> 查看颜色序列，以及其他两个隐藏属性</h4>
<p>​</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br></pre></td><td class="code"><pre><span class="line">co.getOrder() <span class="comment">#查看序列</span></span><br><span class="line">co.getLength() <span class="comment">#查看序列长度</span></span><br><span class="line">co.getBaseOrderNumber() <span class="comment">#查看该序列由几个基础序列混合而成</span></span><br><span class="line"></span><br><span class="line">结果：</span><br><span class="line">[<span class="string">&#x27;#2F0000&#x27;</span>, <span class="string">&#x27;#000079&#x27;</span>, <span class="string">&#x27;#4D0000&#x27;</span>, <span class="string">&#x27;#000093&#x27;</span>, <span class="string">&#x27;#600000&#x27;</span>, <span class="string">&#x27;#0000C6&#x27;</span>, <span class="string">&#x27;#750000&#x27;</span>, <span class="string">&#x27;#0000C6&#x27;</span>, <span class="string">&#x27;#930000&#x27;</span>, <span class="string">&#x27;#0000E3&#x27;</span>, <span class="string">&#x27;#AE0000&#x27;</span>, <span class="string">&#x27;#2828FF&#x27;</span>, <span class="string">&#x27;#CE0000&#x27;</span>, <span class="string">&#x27;#4A4AFF&#x27;</span>, <span class="string">&#x27;#EA0000&#x27;</span>, <span class="string">&#x27;#6A6AFF&#x27;</span>, <span class="string">&#x27;#FF0000&#x27;</span>, <span class="string">&#x27;#7D7DFF&#x27;</span>, <span class="string">&#x27;#FF2D2D&#x27;</span>, <span class="string">&#x27;#9393FF&#x27;</span>, <span class="string">&#x27;#FF5151&#x27;</span>, <span class="string">&#x27;#AAAAFF&#x27;</span>, <span class="string">&#x27;#ff7575&#x27;</span>, <span class="string">&#x27;#B9B9FF&#x27;</span>, <span class="string">&#x27;#FF9797&#x27;</span>, <span class="string">&#x27;#CECEFF&#x27;</span>, <span class="string">&#x27;#FFB5B5&#x27;</span>, <span class="string">&#x27;#DDDDFF&#x27;</span>, <span class="string">&#x27;#FFD2D2&#x27;</span>, <span class="string">&#x27;#ECECFF&#x27;</span>, <span class="string">&#x27;#FFECEC&#x27;</span>,<span class="string">&#x27;#FBFBFF&#x27;</span>]</span><br><span class="line"><span class="number">32</span></span><br><span class="line"><span class="number">2</span></span><br></pre></td></tr></table></figure>
<h4 id="切片获取序列"><a class="markdownIt-Anchor" href="#切片获取序列"></a> 切片获取序列</h4>
<p>​</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><span class="line">co.getLeft(<span class="literal">False</span>) <span class="comment">#获得序列左边的25%</span></span><br><span class="line">co.getRight(<span class="literal">True</span>) <span class="comment">#获得序列右边的25%</span></span><br><span class="line">co.getMiddle() <span class="comment">#获得序列中间的50%</span></span><br></pre></td></tr></table></figure>
<p>参数分析：<br />
def getLeft(self, muti_section = False):<br />
三个方法只有一个相同的参数，muti_section<br />
当muti_section默认为False 直接根据需求获得序列的前25%或后25%或中间50%<br />
当muti_section为True， 考虑某些时候切片以connect方式混合的序列，他会单独提取每个基础序列的左、右或中间的部分，拼接到一起作为返回结果</p>
<h4 id="与colororder对象的序列混合"><a class="markdownIt-Anchor" href="#与colororder对象的序列混合"></a> 与ColorOrder对象的序列混合</h4>
<p>​</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">co.mix(co,<span class="string">&#x27;cross&#x27;</span>)</span><br></pre></td></tr></table></figure>
<p>参数解析：<br />
def mix(self, co, mixtype = ‘Connect’)<br />
co为实例对象，mixtype与__init__中的mixtype相同<br />
值得一提的是这时两个序列不一定时等长的，我们再举一个cross混合的例子。假设混合[2,3,4,2,3,4,2,3,4]和[0,1,0,1,0,1]两个序列，最后的结果是[2,3,4,0,1,2,3,4,0,1,2,3,4,0<br />
1]</p>
<h2 id="应用简例"><a class="markdownIt-Anchor" href="#应用简例"></a> 应用简例</h2>
<p>​</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><span class="line">%matplotlib inline</span><br><span class="line"><span class="keyword">import</span> InterestingColorfulColor <span class="keyword">as</span> ICC</span><br><span class="line"><span class="keyword">import</span> matplotlib.pyplot <span class="keyword">as</span> plt</span><br><span class="line"></span><br><span class="line">fig, ax = plt.subplots(<span class="number">1</span>,<span class="number">2</span>,figsize = (<span class="number">16</span>,<span class="number">8</span>))</span><br><span class="line"></span><br><span class="line">co = ICC.ColorOrder([<span class="string">&#x27;blue&#x27;</span>,<span class="string">&#x27;redpurple&#x27;</span>],<span class="string">&#x27;cross&#x27;</span>)</span><br><span class="line">ax[<span class="number">0</span>].pie([<span class="number">1</span>]*<span class="built_in">len</span>(co.getOrder()),colors = co.getOrder())</span><br><span class="line"></span><br><span class="line">co.mix(ICC.ColorOrder([<span class="string">&#x27;Green&#x27;</span>]),<span class="string">&#x27;cross&#x27;</span>)</span><br><span class="line">ax[<span class="number">1</span>].pie([<span class="number">1</span>]*<span class="built_in">len</span>(co.getMiddle()),colors = co.getMiddle())</span><br></pre></td></tr></table></figure>
<p>效果：<br />
![在这里插入图片描述](<a target="_blank" rel="noopener" href="https://img-blog.csdnimg.cn/20210209204037167.png?x-oss-">https://img-blog.csdnimg.cn/20210209204037167.png?x-oss-</a><br />
process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dsZGNtenk=,size_16,color_FFFFFF,t_70#pic_center)</p>
<h2 id="-11"><a class="markdownIt-Anchor" href="#-11"></a> %……&amp;%￥……？？？？？！！！</h2>
<p>弄到颜色序列之后是可以用co.getOrder()导出来自己随便切的，并不是只能按照getMiddle,getLeft,getRight的固定方式切片</p>
<h2 id="源代码"><a class="markdownIt-Anchor" href="#源代码"></a> 源代码</h2>
<p>​</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br><span class="line">129</span><br><span class="line">130</span><br><span class="line">131</span><br><span class="line">132</span><br><span class="line">133</span><br><span class="line">134</span><br><span class="line">135</span><br><span class="line">136</span><br><span class="line">137</span><br><span class="line">138</span><br><span class="line">139</span><br><span class="line">140</span><br><span class="line">141</span><br><span class="line">142</span><br><span class="line">143</span><br></pre></td><td class="code"><pre><span class="line"><span class="keyword">class</span> <span class="title class_">ICC_UnknowColorName</span>(<span class="title class_ inherited__">Exception</span>):</span><br><span class="line">    <span class="keyword">pass</span></span><br><span class="line"><span class="keyword">class</span> <span class="title class_">ICC_UnknowMixType</span>(<span class="title class_ inherited__">Exception</span>):</span><br><span class="line">    <span class="keyword">pass</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">class</span> <span class="title class_">ColorOrder</span>:</span><br><span class="line">    BaseOrderLength_Normal = <span class="number">16</span></span><br><span class="line">    <span class="comment">#BaseOrderLength_Dull   = 12</span></span><br><span class="line">    ErrorText_ICC_UnknowColorName = <span class="string">&#x27;Exist color name not in ColorOrder.ColorMap, can not identify what color the name means. Or you need to use an iteratable object to iteratable object all color names&#x27;</span></span><br><span class="line">    ErrorText_ICC_UnknowMixType = <span class="string">&#x27;Can not identify mixtype&#x27;</span></span><br><span class="line">    ColorMap = &#123; </span><br><span class="line">         <span class="string">&#x27;Gray&#x27;</span>        : <span class="string">&#x27;Gray&#x27;</span></span><br><span class="line">        ,<span class="string">&#x27;Red&#x27;</span>         : <span class="string">&#x27;Red&#x27;</span></span><br><span class="line">        ,<span class="string">&#x27;Redpurple&#x27;</span>   : <span class="string">&#x27;RedPurple&#x27;</span></span><br><span class="line">        ,<span class="string">&#x27;Purplered&#x27;</span>   : <span class="string">&#x27;RedPurple&#x27;</span></span><br><span class="line">        ,<span class="string">&#x27;Purple&#x27;</span>      : <span class="string">&#x27;Purple&#x27;</span></span><br><span class="line">        ,<span class="string">&#x27;Purpleblue&#x27;</span>  : <span class="string">&#x27;PurpleBlue&#x27;</span></span><br><span class="line">        ,<span class="string">&#x27;Bluepurple&#x27;</span>  : <span class="string">&#x27;PurpleBlue&#x27;</span></span><br><span class="line">        ,<span class="string">&#x27;Blue&#x27;</span>        : <span class="string">&#x27;Blue&#x27;</span></span><br><span class="line">        ,<span class="string">&#x27;Bluecyan&#x27;</span>    : <span class="string">&#x27;BlueCyan&#x27;</span></span><br><span class="line">        ,<span class="string">&#x27;Cyanblue&#x27;</span>    : <span class="string">&#x27;BlueCyan&#x27;</span></span><br><span class="line">        ,<span class="string">&#x27;Cyan&#x27;</span>        : <span class="string">&#x27;Cyan&#x27;</span></span><br><span class="line">        ,<span class="string">&#x27;Cyangreen&#x27;</span>   : <span class="string">&#x27;CyanGreen&#x27;</span></span><br><span class="line">        ,<span class="string">&#x27;Greencyan&#x27;</span>   : <span class="string">&#x27;CyanGreen&#x27;</span></span><br><span class="line">        ,<span class="string">&#x27;Green&#x27;</span>       : <span class="string">&#x27;Green&#x27;</span></span><br><span class="line">        ,<span class="string">&#x27;Greenyellow&#x27;</span> : <span class="string">&#x27;GreenYellow&#x27;</span></span><br><span class="line">        ,<span class="string">&#x27;Yellowgreen&#x27;</span> : <span class="string">&#x27;GreenYellow&#x27;</span></span><br><span class="line">        ,<span class="string">&#x27;Yellow&#x27;</span>      : <span class="string">&#x27;Yellow&#x27;</span></span><br><span class="line">        ,<span class="string">&#x27;Yelloworange&#x27;</span>: <span class="string">&#x27;YellowOrange&#x27;</span></span><br><span class="line">        ,<span class="string">&#x27;Orangeyellow&#x27;</span>: <span class="string">&#x27;YellowOrange&#x27;</span></span><br><span class="line">        ,<span class="string">&#x27;Orange&#x27;</span>      : <span class="string">&#x27;Orange&#x27;</span></span><br><span class="line">        ,<span class="string">&#x27;Orangered&#x27;</span>   : <span class="string">&#x27;OrangeRed&#x27;</span></span><br><span class="line">        ,<span class="string">&#x27;Redorange&#x27;</span>   : <span class="string">&#x27;OrangeRed&#x27;</span></span><br><span class="line">        <span class="comment">#,&#x27;Dullred&#x27;     : &#x27;DullRed&#x27;</span></span><br><span class="line">        <span class="comment">#,&#x27;Dullyellow&#x27;  : &#x27;DullYellow&#x27;</span></span><br><span class="line">        <span class="comment">#,&#x27;Dullcyan&#x27;    : &#x27;DullCyan&#x27;</span></span><br><span class="line">        <span class="comment">#,&#x27;Dullblue&#x27;    : &#x27;DullBlue&#x27;</span></span><br><span class="line">        <span class="comment">#,&#x27;Dullpurple&#x27;  : &#x27;DullPurple&#x27;</span></span><br><span class="line">    &#125;</span><br><span class="line">    BaseColorOrder = &#123; </span><br><span class="line">         <span class="string">&#x27;Gray&#x27;</span>        :   [<span class="string">&#x27;#ffffff&#x27;</span>,<span class="string">&#x27;#272727&#x27;</span>,<span class="string">&#x27;#3C3C3C&#x27;</span>,<span class="string">&#x27;#4F4F4F&#x27;</span>,<span class="string">&#x27;#5B5B5B&#x27;</span>,<span class="string">&#x27;#6C6C6C&#x27;</span>,<span class="string">&#x27;#7B7B7B&#x27;</span>,<span class="string">&#x27;#8E8E8E&#x27;</span>,<span class="string">&#x27;#9D9D9D&#x27;</span>,<span class="string">&#x27;#ADADAD&#x27;</span>,<span class="string">&#x27;#BEBEBE&#x27;</span>,<span class="string">&#x27;#d0d0d0&#x27;</span>,<span class="string">&#x27;#E0E0E0&#x27;</span>,<span class="string">&#x27;#F0F0F0&#x27;</span>,<span class="string">&#x27;#FCFCFC&#x27;</span>,<span class="string">&#x27;#FFFFFF&#x27;</span>]</span><br><span class="line">        ,<span class="string">&#x27;Red&#x27;</span>         :   [<span class="string">&#x27;#2F0000&#x27;</span>,<span class="string">&#x27;#4D0000&#x27;</span>,<span class="string">&#x27;#600000&#x27;</span>,<span class="string">&#x27;#750000&#x27;</span>,<span class="string">&#x27;#930000&#x27;</span>,<span class="string">&#x27;#AE0000&#x27;</span>,<span class="string">&#x27;#CE0000&#x27;</span>,<span class="string">&#x27;#EA0000&#x27;</span>,<span class="string">&#x27;#FF0000&#x27;</span>,<span class="string">&#x27;#FF2D2D&#x27;</span>,<span class="string">&#x27;#FF5151&#x27;</span>,<span class="string">&#x27;#ff7575&#x27;</span>,<span class="string">&#x27;#FF9797&#x27;</span>,<span class="string">&#x27;#FFB5B5&#x27;</span>,<span class="string">&#x27;#FFD2D2&#x27;</span>,<span class="string">&#x27;#FFECEC&#x27;</span>]</span><br><span class="line">        ,<span class="string">&#x27;RedPurple&#x27;</span>   :   [<span class="string">&#x27;#600030&#x27;</span>,<span class="string">&#x27;#820041&#x27;</span>,<span class="string">&#x27;#9F0050&#x27;</span>,<span class="string">&#x27;#BF0060&#x27;</span>,<span class="string">&#x27;#D9006C&#x27;</span>,<span class="string">&#x27;#F00078&#x27;</span>,<span class="string">&#x27;#FF0080&#x27;</span>,<span class="string">&#x27;#FF359A&#x27;</span>,<span class="string">&#x27;#FF60AF&#x27;</span>,<span class="string">&#x27;#FF79BC&#x27;</span>,<span class="string">&#x27;#FF95CA&#x27;</span>,<span class="string">&#x27;#ffaad5&#x27;</span>,<span class="string">&#x27;#FFC1E0&#x27;</span>,<span class="string">&#x27;#FFD9EC&#x27;</span>,<span class="string">&#x27;#FFECF5&#x27;</span>,<span class="string">&#x27;#FFF7FB&#x27;</span>]</span><br><span class="line">        ,<span class="string">&#x27;Purple&#x27;</span>      :   [<span class="string">&#x27;#460046&#x27;</span>,<span class="string">&#x27;#5E005E&#x27;</span>,<span class="string">&#x27;#750075&#x27;</span>,<span class="string">&#x27;#930093&#x27;</span>,<span class="string">&#x27;#AE00AE&#x27;</span>,<span class="string">&#x27;#D200D2&#x27;</span>,<span class="string">&#x27;#E800E8&#x27;</span>,<span class="string">&#x27;#FF00FF&#x27;</span>,<span class="string">&#x27;#FF44FF&#x27;</span>,<span class="string">&#x27;#FF77FF&#x27;</span>,<span class="string">&#x27;#FF8EFF&#x27;</span>,<span class="string">&#x27;#ffa6ff&#x27;</span>,<span class="string">&#x27;#FFBFFF&#x27;</span>,<span class="string">&#x27;#FFD0FF&#x27;</span>,<span class="string">&#x27;#FFE6FF&#x27;</span>,<span class="string">&#x27;#FFF7FF&#x27;</span>]</span><br><span class="line">        ,<span class="string">&#x27;PurpleBlue&#x27;</span>  :   [<span class="string">&#x27;#28004D&#x27;</span>,<span class="string">&#x27;#3A006F&#x27;</span>,<span class="string">&#x27;#4B0091&#x27;</span>,<span class="string">&#x27;#5B00AE&#x27;</span>,<span class="string">&#x27;#6F00D2&#x27;</span>,<span class="string">&#x27;#8600FF&#x27;</span>,<span class="string">&#x27;#921AFF&#x27;</span>,<span class="string">&#x27;#9F35FF&#x27;</span>,<span class="string">&#x27;#B15BFF&#x27;</span>,<span class="string">&#x27;#BE77FF&#x27;</span>,<span class="string">&#x27;#CA8EFF&#x27;</span>,<span class="string">&#x27;#d3a4ff&#x27;</span>,<span class="string">&#x27;#DCB5FF&#x27;</span>,<span class="string">&#x27;#E6CAFF&#x27;</span>,<span class="string">&#x27;#F1E1FF&#x27;</span>,<span class="string">&#x27;#FAF4FF&#x27;</span>]</span><br><span class="line">        ,<span class="string">&#x27;Blue&#x27;</span>        :   [<span class="string">&#x27;#000079&#x27;</span>,<span class="string">&#x27;#000093&#x27;</span>,<span class="string">&#x27;#0000C6&#x27;</span>,<span class="string">&#x27;#0000C6&#x27;</span>,<span class="string">&#x27;#0000E3&#x27;</span>,<span class="string">&#x27;#2828FF&#x27;</span>,<span class="string">&#x27;#4A4AFF&#x27;</span>,<span class="string">&#x27;#6A6AFF&#x27;</span>,<span class="string">&#x27;#7D7DFF&#x27;</span>,<span class="string">&#x27;#9393FF&#x27;</span>,<span class="string">&#x27;#AAAAFF&#x27;</span>,<span class="string">&#x27;#B9B9FF&#x27;</span>,<span class="string">&#x27;#CECEFF&#x27;</span>,<span class="string">&#x27;#DDDDFF&#x27;</span>,<span class="string">&#x27;#ECECFF&#x27;</span>,<span class="string">&#x27;#FBFBFF&#x27;</span>]</span><br><span class="line">        ,<span class="string">&#x27;BlueCyan&#x27;</span>    :   [<span class="string">&#x27;#000079&#x27;</span>,<span class="string">&#x27;#003D79&#x27;</span>,<span class="string">&#x27;#004B97&#x27;</span>,<span class="string">&#x27;#005AB5&#x27;</span>,<span class="string">&#x27;#0066CC&#x27;</span>,<span class="string">&#x27;#0072E3&#x27;</span>,<span class="string">&#x27;#0080FF&#x27;</span>,<span class="string">&#x27;#2894FF&#x27;</span>,<span class="string">&#x27;#46A3FF&#x27;</span>,<span class="string">&#x27;#66B3FF&#x27;</span>,<span class="string">&#x27;#84C1FF&#x27;</span>,<span class="string">&#x27;#97CBFF&#x27;</span>,<span class="string">&#x27;#ACD6FF&#x27;</span>,<span class="string">&#x27;#C4E1FF&#x27;</span>,<span class="string">&#x27;#D2E9FF&#x27;</span>,<span class="string">&#x27;#ECF5FF&#x27;</span>]</span><br><span class="line">        ,<span class="string">&#x27;Cyan&#x27;</span>        :   [<span class="string">&#x27;#003E3E&#x27;</span>,<span class="string">&#x27;#005757&#x27;</span>,<span class="string">&#x27;#007979&#x27;</span>,<span class="string">&#x27;#009393&#x27;</span>,<span class="string">&#x27;#00AEAE&#x27;</span>,<span class="string">&#x27;#00CACA&#x27;</span>,<span class="string">&#x27;#00E3E3&#x27;</span>,<span class="string">&#x27;#00FFFF&#x27;</span>,<span class="string">&#x27;#4DFFFF&#x27;</span>,<span class="string">&#x27;#80FFFF&#x27;</span>,<span class="string">&#x27;#A6FFFF&#x27;</span>,<span class="string">&#x27;#BBFFFF&#x27;</span>,<span class="string">&#x27;#CAFFFF&#x27;</span>,<span class="string">&#x27;#D9FFFF&#x27;</span>,<span class="string">&#x27;#ECFFFF&#x27;</span>,<span class="string">&#x27;#FDFFFF&#x27;</span>]</span><br><span class="line">        ,<span class="string">&#x27;CyanGreen&#x27;</span>   :   [<span class="string">&#x27;#006030&#x27;</span>,<span class="string">&#x27;#01814A&#x27;</span>,<span class="string">&#x27;#019858&#x27;</span>,<span class="string">&#x27;#01B468&#x27;</span>,<span class="string">&#x27;#02C874&#x27;</span>,<span class="string">&#x27;#02DF82&#x27;</span>,<span class="string">&#x27;#02F78E&#x27;</span>,<span class="string">&#x27;#1AFD9C&#x27;</span>,<span class="string">&#x27;#4EFEB3&#x27;</span>,<span class="string">&#x27;#7AFEC6&#x27;</span>,<span class="string">&#x27;#96FED1&#x27;</span>,<span class="string">&#x27;#ADFEDC&#x27;</span>,<span class="string">&#x27;#C1FFE4&#x27;</span>,<span class="string">&#x27;#D7FFEE&#x27;</span>,<span class="string">&#x27;#E8FFF5&#x27;</span>,<span class="string">&#x27;#FBFFFD&#x27;</span>]</span><br><span class="line">        ,<span class="string">&#x27;Green&#x27;</span>       :   [<span class="string">&#x27;#006000&#x27;</span>,<span class="string">&#x27;#007500&#x27;</span>,<span class="string">&#x27;#009100&#x27;</span>,<span class="string">&#x27;#00A600&#x27;</span>,<span class="string">&#x27;#00BB00&#x27;</span>,<span class="string">&#x27;#00DB00&#x27;</span>,<span class="string">&#x27;#00EC00&#x27;</span>,<span class="string">&#x27;#28FF28&#x27;</span>,<span class="string">&#x27;#53FF53&#x27;</span>,<span class="string">&#x27;#79FF79&#x27;</span>,<span class="string">&#x27;#93FF93&#x27;</span>,<span class="string">&#x27;#A6FFA6&#x27;</span>,<span class="string">&#x27;#BBFFBB&#x27;</span>,<span class="string">&#x27;#CEFFCE&#x27;</span>,<span class="string">&#x27;#DFFFDF&#x27;</span>,<span class="string">&#x27;#F0FFF0&#x27;</span>]</span><br><span class="line">        ,<span class="string">&#x27;GreenYellow&#x27;</span> :   [<span class="string">&#x27;#467500&#x27;</span>,<span class="string">&#x27;#548C00&#x27;</span>,<span class="string">&#x27;#64A600&#x27;</span>,<span class="string">&#x27;#73BF00&#x27;</span>,<span class="string">&#x27;#82D900&#x27;</span>,<span class="string">&#x27;#8CEA00&#x27;</span>,<span class="string">&#x27;#9AFF02&#x27;</span>,<span class="string">&#x27;#A8FF24&#x27;</span>,<span class="string">&#x27;#B7FF4A&#x27;</span>,<span class="string">&#x27;#C2FF68&#x27;</span>,<span class="string">&#x27;#CCFF80&#x27;</span>,<span class="string">&#x27;#D3FF93&#x27;</span>,<span class="string">&#x27;#DEFFAC&#x27;</span>,<span class="string">&#x27;#E8FFC4&#x27;</span>,<span class="string">&#x27;#EFFFD7&#x27;</span>,<span class="string">&#x27;#F5FFE8&#x27;</span>]</span><br><span class="line">        ,<span class="string">&#x27;Yellow&#x27;</span>      :   [<span class="string">&#x27;#424200&#x27;</span>,<span class="string">&#x27;#5B5B00&#x27;</span>,<span class="string">&#x27;#737300&#x27;</span>,<span class="string">&#x27;#8C8C00&#x27;</span>,<span class="string">&#x27;#A6A600&#x27;</span>,<span class="string">&#x27;#C4C400&#x27;</span>,<span class="string">&#x27;#E1E100&#x27;</span>,<span class="string">&#x27;#F9F900&#x27;</span>,<span class="string">&#x27;#FFFF37&#x27;</span>,<span class="string">&#x27;#FFFF6F&#x27;</span>,<span class="string">&#x27;#FFFF93&#x27;</span>,<span class="string">&#x27;#FFFFAA&#x27;</span>,<span class="string">&#x27;#FFFFB9&#x27;</span>,<span class="string">&#x27;#FFFFCE&#x27;</span>,<span class="string">&#x27;#FFFFDF&#x27;</span>,<span class="string">&#x27;#FFFFF4&#x27;</span>]</span><br><span class="line">        ,<span class="string">&#x27;YellowOrange&#x27;</span>:   [<span class="string">&#x27;#5B4B00&#x27;</span>,<span class="string">&#x27;#796400&#x27;</span>,<span class="string">&#x27;#977C00&#x27;</span>,<span class="string">&#x27;#AE8F00&#x27;</span>,<span class="string">&#x27;#C6A300&#x27;</span>,<span class="string">&#x27;#D9B300&#x27;</span>,<span class="string">&#x27;#EAC100&#x27;</span>,<span class="string">&#x27;#FFD306&#x27;</span>,<span class="string">&#x27;#FFDC35&#x27;</span>,<span class="string">&#x27;#FFE153&#x27;</span>,<span class="string">&#x27;#FFE66F&#x27;</span>,<span class="string">&#x27;#FFED97&#x27;</span>,<span class="string">&#x27;#FFF0AC&#x27;</span>,<span class="string">&#x27;#FFF4C1&#x27;</span>,<span class="string">&#x27;#FFF8D7&#x27;</span>,<span class="string">&#x27;#FFFCEC&#x27;</span>]</span><br><span class="line">        ,<span class="string">&#x27;Orange&#x27;</span>      :   [<span class="string">&#x27;#844200&#x27;</span>,<span class="string">&#x27;#9F5000&#x27;</span>,<span class="string">&#x27;#BB5E00&#x27;</span>,<span class="string">&#x27;#D26900&#x27;</span>,<span class="string">&#x27;#EA7500&#x27;</span>,<span class="string">&#x27;#FF8000&#x27;</span>,<span class="string">&#x27;#FF9224&#x27;</span>,<span class="string">&#x27;#FFA042&#x27;</span>,<span class="string">&#x27;#FFAF60&#x27;</span>,<span class="string">&#x27;#FFBB77&#x27;</span>,<span class="string">&#x27;#FFC78E&#x27;</span>,<span class="string">&#x27;#FFD1A4&#x27;</span>,<span class="string">&#x27;#FFDCB9&#x27;</span>,<span class="string">&#x27;#FFE4CA&#x27;</span>,<span class="string">&#x27;#FFEEDD&#x27;</span>,<span class="string">&#x27;#FFFAF4&#x27;</span>]</span><br><span class="line">        ,<span class="string">&#x27;OrangeRed&#x27;</span>   :   [<span class="string">&#x27;#642100&#x27;</span>,<span class="string">&#x27;#842B00&#x27;</span>,<span class="string">&#x27;#A23400&#x27;</span>,<span class="string">&#x27;#BB3D00&#x27;</span>,<span class="string">&#x27;#D94600&#x27;</span>,<span class="string">&#x27;#F75000&#x27;</span>,<span class="string">&#x27;#FF5809&#x27;</span>,<span class="string">&#x27;#FF8040&#x27;</span>,<span class="string">&#x27;#FF8F59&#x27;</span>,<span class="string">&#x27;#FF9D6F&#x27;</span>,<span class="string">&#x27;#FFAD86&#x27;</span>,<span class="string">&#x27;#FFBD9D&#x27;</span>,<span class="string">&#x27;#FFCBB3&#x27;</span>,<span class="string">&#x27;#FFDAC8&#x27;</span>,<span class="string">&#x27;#FFE6D9&#x27;</span>,<span class="string">&#x27;#FFF3EE&#x27;</span>]</span><br><span class="line">        <span class="comment">#,&#x27;DullRed&#x27;     :   [&#x27;#613030&#x27;,&#x27;#743A3A&#x27;,&#x27;#804040&#x27;,&#x27;#984B4B&#x27;,&#x27;#AD5A5A&#x27;,&#x27;#B87070&#x27;,&#x27;#C48888&#x27;,&#x27;#CF9E9E&#x27;,&#x27;#D9B3B3&#x27;,&#x27;#E1C4C4&#x27;,&#x27;#EBD6D6&#x27;,&#x27;#F2E6E6&#x27;]</span></span><br><span class="line">        <span class="comment">#,&#x27;DullYellow&#x27;  :   [&#x27;#616130&#x27;,&#x27;#707038&#x27;,&#x27;#808040&#x27;,&#x27;#949449&#x27;,&#x27;#A5A552&#x27;,&#x27;#AFAF61&#x27;,&#x27;#B9B973&#x27;,&#x27;#C2C287&#x27;,&#x27;#CDCD9A&#x27;,&#x27;#D6D6AD&#x27;,&#x27;#DEDEBE&#x27;,&#x27;#E8E8D0&#x27;]</span></span><br><span class="line">        <span class="comment">#,&#x27;DullCyan&#x27;    :   [&#x27;#336666&#x27;,&#x27;#3D7878&#x27;,&#x27;#408080&#x27;,&#x27;#4F9D9D&#x27;,&#x27;#5CADAD&#x27;,&#x27;#6FB7B7&#x27;,&#x27;#81C0C0&#x27;,&#x27;#95CACA&#x27;,&#x27;#A3D1D1&#x27;,&#x27;#B3D9D9&#x27;,&#x27;#C4E1E1&#x27;,&#x27;#D1E9E9&#x27;]</span></span><br><span class="line">        <span class="comment">#,&#x27;DullBlue&#x27;    :   [&#x27;#484891&#x27;,&#x27;#5151A2&#x27;,&#x27;#5A5AAD&#x27;,&#x27;#7373B9&#x27;,&#x27;#8080C0&#x27;,&#x27;#9999CC&#x27;,&#x27;#A6A6D2&#x27;,&#x27;#B8B8DC&#x27;,&#x27;#C7C7E2&#x27;,&#x27;#D8D8EB&#x27;,&#x27;#E6E6F2&#x27;,&#x27;#F3F3FA&#x27;]</span></span><br><span class="line">        <span class="comment">#,&#x27;DullPurple&#x27;  :   [&#x27;#6C3365&#x27;,&#x27;#7E3D76&#x27;,&#x27;#8F4586&#x27;,&#x27;#9F4D95&#x27;,&#x27;#AE57A4&#x27;,&#x27;#B766AD&#x27;,&#x27;#C07AB8&#x27;,&#x27;#CA8EC2&#x27;,&#x27;#D2A2CC&#x27;,&#x27;#DAB1D5&#x27;,&#x27;#E2C2DE&#x27;,&#x27;#EBD3E8&#x27;]</span></span><br><span class="line">      &#125;</span><br><span class="line">    </span><br><span class="line">    <span class="keyword">def</span> <span class="title function_">__init__</span>(<span class="params">self, colornames, mixtype = <span class="string">&#x27;Connect&#x27;</span></span>):</span><br><span class="line">        colornames = [i.capitalize() <span class="keyword">for</span> i <span class="keyword">in</span> colornames]</span><br><span class="line">        mixtype = mixtype.capitalize()</span><br><span class="line">        <span class="keyword">for</span> each <span class="keyword">in</span> colornames:</span><br><span class="line">            <span class="keyword">if</span> each <span class="keyword">not</span> <span class="keyword">in</span> ColorOrder.ColorMap:</span><br><span class="line">                <span class="keyword">raise</span> ICC_UnknowColorName(ColorOrder.ErrorText_ICC_UnknowColorName)</span><br><span class="line">                </span><br><span class="line">        self.__order = []</span><br><span class="line">        <span class="keyword">if</span> mixtype == <span class="string">&#x27;Connect&#x27;</span>:</span><br><span class="line">            <span class="keyword">for</span> eachname <span class="keyword">in</span> colornames:</span><br><span class="line">                self.__order.extend(ColorOrder.BaseColorOrder[ColorOrder.ColorMap[eachname]])</span><br><span class="line">        <span class="keyword">elif</span> mixtype == <span class="string">&#x27;Cross&#x27;</span>:</span><br><span class="line">            lst = []</span><br><span class="line">            <span class="keyword">for</span> eachname <span class="keyword">in</span> colornames:</span><br><span class="line">                lst.append(ColorOrder.BaseColorOrder[ColorOrder.ColorMap[eachname]])</span><br><span class="line">            <span class="keyword">for</span> i <span class="keyword">in</span> <span class="built_in">range</span>(ColorOrder.BaseOrderLength_Normal):</span><br><span class="line">                <span class="keyword">for</span> each <span class="keyword">in</span> lst:</span><br><span class="line">                    self.__order.append(each[i])</span><br><span class="line">        <span class="keyword">else</span>:</span><br><span class="line">            <span class="keyword">raise</span> ICC_UnknowMixType(ColorOrder.ErrorText_ICC_UnknowMixType)</span><br><span class="line">            </span><br><span class="line">        self.__baseOrderNumber = <span class="built_in">len</span>(colornames)</span><br><span class="line">        self.__length = self.__baseOrderNumber * ColorOrder.BaseOrderLength_Normal</span><br><span class="line">    </span><br><span class="line">    <span class="keyword">def</span> <span class="title function_">getBaseOrderNumber</span>(<span class="params">self</span>):</span><br><span class="line">        <span class="keyword">return</span> self.__baseOrderNumber</span><br><span class="line">    </span><br><span class="line">    <span class="keyword">def</span> <span class="title function_">getLength</span>(<span class="params">self</span>):</span><br><span class="line">        <span class="keyword">return</span> self.__length</span><br><span class="line">    </span><br><span class="line">    <span class="keyword">def</span> <span class="title function_">getOrder</span>(<span class="params">self</span>):</span><br><span class="line">        <span class="keyword">return</span> self.__order.copy()</span><br><span class="line">    </span><br><span class="line">    <span class="keyword">def</span> <span class="title function_">getLeft</span>(<span class="params">self, muti_section = <span class="literal">False</span></span>):</span><br><span class="line">        <span class="keyword">if</span> muti_section == <span class="literal">False</span>:</span><br><span class="line">            lst = self.__order[ : <span class="number">4</span> * self.__baseOrderNumber ]</span><br><span class="line">        <span class="keyword">else</span>:</span><br><span class="line">            lst = []</span><br><span class="line">            <span class="keyword">for</span> i <span class="keyword">in</span> <span class="built_in">range</span>(self.__baseOrderNumber):</span><br><span class="line">                pos = i * ColorOrder.BaseOrderLength_Normal</span><br><span class="line">                lst.extend(self.__order[ pos : pos + <span class="number">4</span>])</span><br><span class="line">        <span class="keyword">return</span> lst</span><br><span class="line">    </span><br><span class="line">    <span class="keyword">def</span> <span class="title function_">getRight</span>(<span class="params">self, muti_section = <span class="literal">False</span></span>):</span><br><span class="line">        <span class="keyword">if</span> muti_section == <span class="literal">False</span>:</span><br><span class="line">            lst = self.__order[ -<span class="number">4</span> * self.__baseOrderNumber : ]</span><br><span class="line">        <span class="keyword">else</span>:</span><br><span class="line">            lst = []</span><br><span class="line">            <span class="keyword">for</span> i <span class="keyword">in</span> <span class="built_in">range</span>(<span class="number">1</span>,self.__baseOrderNumber+<span class="number">1</span>):</span><br><span class="line">                pos = i * ColorOrder.BaseOrderLength_Normal</span><br><span class="line">                lst.extend(self.__order[ pos - <span class="number">4</span> : pos])</span><br><span class="line">        <span class="keyword">return</span> lst</span><br><span class="line">    </span><br><span class="line">    <span class="keyword">def</span> <span class="title function_">getMiddle</span>(<span class="params">self, muti_section = <span class="literal">False</span></span>):</span><br><span class="line">        <span class="keyword">if</span> muti_section == <span class="literal">False</span>:</span><br><span class="line">            lst = self.__order[ <span class="number">4</span> * self.__baseOrderNumber : <span class="number">12</span> * self.__baseOrderNumber ]</span><br><span class="line">        <span class="keyword">else</span>:</span><br><span class="line">            lst = []</span><br><span class="line">            <span class="keyword">for</span> i <span class="keyword">in</span> <span class="built_in">range</span>(self.__baseOrderNumber):</span><br><span class="line">                pos = i * ColorOrder.BaseOrderLength_Normal</span><br><span class="line">                lst.extend(self.__order[ pos + <span class="number">4</span> : pos + <span class="number">12</span>])</span><br><span class="line">        <span class="keyword">return</span> lst</span><br><span class="line">    </span><br><span class="line">    <span class="keyword">def</span> <span class="title function_">mix</span>(<span class="params">self, co, mixtype = <span class="string">&#x27;Connect&#x27;</span></span>):</span><br><span class="line">        mixtype = mixtype.capitalize()</span><br><span class="line">        <span class="keyword">if</span> mixtype == <span class="string">&#x27;Connect&#x27;</span>:</span><br><span class="line">            self.__order.extend(co.__order)</span><br><span class="line">        <span class="keyword">elif</span> mixtype == <span class="string">&#x27;Cross&#x27;</span>:</span><br><span class="line">            lst = []</span><br><span class="line">            idx1 = <span class="number">0</span></span><br><span class="line">            idx2 = <span class="number">0</span></span><br><span class="line">            <span class="keyword">for</span> i <span class="keyword">in</span> <span class="built_in">range</span>(ColorOrder.BaseOrderLength_Normal):</span><br><span class="line">                <span class="keyword">for</span> j <span class="keyword">in</span> <span class="built_in">range</span>(self.__baseOrderNumber):</span><br><span class="line">                    lst.append(self.__order[idx1])</span><br><span class="line">                    idx1 += <span class="number">1</span></span><br><span class="line">                <span class="keyword">for</span> j <span class="keyword">in</span> <span class="built_in">range</span>(co.__baseOrderNumber):</span><br><span class="line">                    lst.append(co.__order[idx2])</span><br><span class="line">                    idx2 += <span class="number">1</span></span><br><span class="line">            self.__order = lst</span><br><span class="line">        self.__length += co.__length</span><br><span class="line">        self.__baseOrderNumber += co.__baseOrderNumber</span><br></pre></td></tr></table></figure>
<p>​</p>

      
    </div>
    <footer class="article-footer">
      <a data-url="http://example.com/1111/11/11/python%20%E7%AE%80%E5%8D%95%E7%9A%84%E9%A2%9C%E8%89%B2%E5%BA%8F%E5%88%97%E7%94%9F%E6%88%90%E5%99%A8/" data-id="cl2uhoebq000pe4j3195h55se" class="article-share-link">分享</a>
      
      
  <ul class="article-tag-list" itemprop="keywords"><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/OldBlog-Before20220505/" rel="tag">OldBlog(Before20220505)</a></li><li class="article-tag-list-item"><a class="article-tag-list-link" href="/tags/%E7%94%BB%E5%9B%BE/" rel="tag">画图</a></li></ul>

    </footer>
  </div>
  
</article>




  


  <nav id="page-nav">
    <a class="extend prev" rel="prev" href="/">&lt;&lt;&lt; 上一页</a><a class="page-number" href="/">1</a><span class="page-number current">2</span><a class="page-number" href="/page/3/">3</a><a class="page-number" href="/page/4/">4</a><span class="space">&hellip;</span><a class="page-number" href="/page/8/">8</a><a class="extend next" rel="next" href="/page/3/">下一页 &gt;&gt;&gt;</a>
  </nav>
</section>
        
          <aside id="sidebar">
  
    <div class="widget-wrap">
  <h3 class="widget-title"></h3>
  <div class="widget">
    <h1 class="blog-title">蓝湖畔淅淅沥沥的雨</h1>
    <h2 class="blog-subtitle">All tragedy erased, I see only wonders...</h2>
    <ul class="blog-link">
     
          <a href="/" title="Home">
            <li>主页</li>
          </a>
        
          <a href="/archives" title="Archives">
            <li>归档</li>
          </a>
        
          <a href="/categories" title="Categories">
            <li>分类</li>
          </a>
        
          <a href="/tags" title="Tags">
            <li>标签</li>
          </a>
        
          <a href="/knightabout" title="Knightabout">
            <li>关于</li>
          </a>
        
          <a href="/bridges" title="Bridges">
            <li>传送门</li>
          </a>
        
          <a href="/announcement" title="Announcement">
            <li>公告</li>
          </a>
        
    </ul>
  </div>
</div>

  
    <div class="widget-wrap">
  <h3 class="widget-title"></h3>
  <div class="widget">
    <img class="avatar" src="/images/avatar.png">
    <h2 class="author">StarsWhisper</h2>
    <h3 class="description"></h3>
    <div class="count-box">
      <a href="/archives"><div><strong>75</strong><br>文章</div></a>
      <a href="/categories"><div><strong>31</strong><br>分类</div></a>
      <a href="/tags"><div><strong>56</strong><br>标签</div></a>
    </div>



    <div class="social-link">
      
        <a class="hvr-bounce-in" href="https://github.com/Wldcmzy" target="_blank" title="Github">
          Github
        </a>
      
        <a class="hvr-bounce-in" href="https://blog.csdn.net/wldcmzy" target="_blank" title="CSDN">
          CSDN
        </a>
      
        <a class="hvr-bounce-in" href="https://space.bilibili.com/83743701" target="_blank" title="bilibili(无技术和学习内容)">
          bilibili(无技术和学习内容)
        </a>
      
    </div>

    <div class="friend-link">
      <h2>友情链接</h2>
      
        <a class="hvr-bounce-in" href="https://shanamaid.github.io/" target="_blank" title="夏娜主题作者的博客">
          夏娜主题作者的博客
        </a>
      
    </div>
  </div>
</div>

  
</aside>
        
      </div>
      <footer id="footer">
  
  <div class="outer">
    <div id="footer-info" class="inner">
      &copy;2021 - 2022 StarsWhisper<br>
      由<a href="http://hexo.io/" target="_blank">Hexo</a>强力驱动 | 
      主题-<a target="_blank" rel="noopener" href="https://github.com/ShanaMaid/hexo-theme-shana">Shana</a>(但是魔改)
      
    </div>
    
  </div>
</footer>
    </div>
    

<script src="//apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
<script src="//apps.bdimg.com/libs/wow/0.1.6/wow.min.js"></script>
<script>
new WOW().init();
</script>   


  
<link rel="stylesheet" href="/plugin/fancybox/jquery.fancybox.css">

  
<script src="/plugin/fancybox/jquery.fancybox.pack.js"></script>




  
<link rel="stylesheet" href="/plugin/galmenu/GalMenu.css">

  
<script src="/plugin/galmenu/GalMenu.js"></script>

  <div class="GalMenu GalDropDown">
      <div class="circle" id="gal">
        <div class="ring">
          
            <a href="/announcement" title="" class="menuItem">公告</a>
          
            <a href="/tags" title="" class="menuItem">标签</a>
          
            <a href="/categories" title="" class="menuItem">分类</a>
          
            <a href="/archives" title="" class="menuItem">归档</a>
          
            <a href="/knightabout" title="" class="menuItem">关于</a>
          
            <a href="/bridges" title="" class="menuItem">传送门</a>
          
        </div>
        
          <audio id="audio" src="#"></audio>
        
      </div> 
</div>
<div id="overlay" style="opacity: 1; cursor: pointer;"></div>
  <script type="text/javascript">var items = document.querySelectorAll('.menuItem');
    for (var i = 0,
    l = items.length; i < l; i++) {
      items[i].style.left = (50 - 35 * Math.cos( - 0.5 * Math.PI - 2 * (1 / l) * i * Math.PI)).toFixed(4) + "%";
      items[i].style.top = (50 + 35 * Math.sin( - 0.5 * Math.PI - 2 * (1 / l) * i * Math.PI)).toFixed(4) + "%"
    }</script>
<script type="text/javascript">
  $(document).ready(function() {
    $('body').GalMenu({
      'menu': 'GalDropDown'
    })
  });
</script>

  <section class="hidden-xs"> 
  <ul class="cb-slideshow"> 
    <li><span>苟利</span></li> 
    <li><span>国家</span></li> 
    <li><span>生死以</span></li> 
    <li><span>岂能</span></li> 
    <li><span>祸福</span></li> 
    <li><span>趋避之</span></li> 
  </ul>
</section>

<script src="/js/script.js"></script>




  </div>
</body>
</html>